Parses the CSR. Returns a dictionary of result values.

    csr_file
        Path to Certificate Signing Request file

    certificate_type
        Type of SSL Certificate. Possible values include:

        - EV Multi Domain SSL
        - EV SSL
        - EV SSL SGC
        - EssentialSSL
        - EssentialSSL Wildcard
        - InstantSSL
        - InstantSSL Pro
        - Multi Domain SSL
        - PositiveSSL
        - PositiveSSL Multi Domain
        - PositiveSSL Wildcard
        - PremiumSSL
        - PremiumSSL Wildcard
        - QuickSSL Premium
        - RapidSSL
        - RapidSSL Wildcard
        - SGC Supercert
        - SSL Web Server
        - SSL Webserver EV
        - SSL123
        - Secure Site
        - Secure Site Pro
        - Secure Site Pro with EV
        - Secure Site with EV
        - True BusinessID
        - True BusinessID Multi Domain
        - True BusinessID Wildcard
        - True BusinessID with EV
        - True BusinessID with EV Multi Domain
        - Unified Communications

    http_dc_validation : False
        Set to ``True`` if a Comodo certificate and validation should be
        done with files instead of emails and to return the info to do so

    CLI Example:

    .. code-block:: bash

        salt 'my-minion' namecheap_ssl.parse_csr my-csr-file PremiumSSL

def parse_csr(csr_file, certificate_type, http_dc_validation=False):
    '''
    Parses the CSR. Returns a dictionary of result values.

    csr_file
        Path to Certificate Signing Request file

    certificate_type
        Type of SSL Certificate. Possible values include:

        - EV Multi Domain SSL
        - EV SSL
        - EV SSL SGC
        - EssentialSSL
        - EssentialSSL Wildcard
        - InstantSSL
        - InstantSSL Pro
        - Multi Domain SSL
        - PositiveSSL
        - PositiveSSL Multi Domain
        - PositiveSSL Wildcard
        - PremiumSSL
        - PremiumSSL Wildcard
        - QuickSSL Premium
        - RapidSSL
        - RapidSSL Wildcard
        - SGC Supercert
        - SSL Web Server
        - SSL Webserver EV
        - SSL123
        - Secure Site
        - Secure Site Pro
        - Secure Site Pro with EV
        - Secure Site with EV
        - True BusinessID
        - True BusinessID Multi Domain
        - True BusinessID Wildcard
        - True BusinessID with EV
        - True BusinessID with EV Multi Domain
        - Unified Communications

    http_dc_validation : False
        Set to ``True`` if a Comodo certificate and validation should be
        done with files instead of emails and to return the info to do so

    CLI Example:

    .. code-block:: bash

        salt 'my-minion' namecheap_ssl.parse_csr my-csr-file PremiumSSL
    '''
    valid_certs = ('QuickSSL Premium',
                   'RapidSSL',
                   'RapidSSL Wildcard',
                   'PremiumSSL',
                   'InstantSSL',
                   'PositiveSSL',
                   'PositiveSSL Wildcard',
                   'True BusinessID with EV',
                   'True BusinessID',
                   'True BusinessID Wildcard',
                   'True BusinessID Multi Domain',
                   'True BusinessID with EV Multi Domain',
                   'Secure Site',
                   'Secure Site Pro',
                   'Secure Site with EV',
                   'Secure Site Pro with EV',
                   'EssentialSSL',
                   'EssentialSSL Wildcard',
                   'InstantSSL Pro',
                   'PremiumSSL Wildcard',
                   'EV SSL',
                   'EV SSL SGC',
                   'SSL123',
                   'SSL Web Server',
                   'SGC Supercert',
                   'SSL Webserver EV',
                   'EV Multi Domain SSL',
                   'Multi Domain SSL',
                   'PositiveSSL Multi Domain',
                   'Unified Communications',
                   )

    if certificate_type not in valid_certs:
        log.error('Invalid option for certificate_type=%s', certificate_type)
        raise Exception('Invalid option for certificate_type=' + certificate_type)

    opts = salt.utils.namecheap.get_opts('namecheap.ssl.parseCSR')

    with salt.utils.files.fopen(csr_file, 'rb') as csr_handle:
        opts['csr'] = salt.utils.stringutils.to_unicode(
            csr_handle.read()
        )

    opts['CertificateType'] = certificate_type
    if http_dc_validation:
        opts['HTTPDCValidation'] = 'true'

    response_xml = salt.utils.namecheap.post_request(opts)

    sslparseresult = response_xml.getElementsByTagName('SSLParseCSRResult')[0]

    return salt.utils.namecheap.xml_to_dict(sslparseresult)