(pem_cert_string)
return base64.decodebytes(d.encode('ASCII', 'strict'))
Takes a certificate in ASCII PEM format and returns the
    DER-encoded version of it as a byte sequence
Takes a certificate in ASCII PEM format and returns the
    DER-encoded version of it as a byte sequence
Takes a certificate in ASCII PEM format and returns the DER - encoded version of it as a byte sequence
def PEM_cert_to_DER_cert(pem_cert_string):
    """Takes a certificate in ASCII PEM format and returns the
    DER-encoded version of it as a byte sequence"""

    if not pem_cert_string.startswith(PEM_HEADER):
        raise ValueError("Invalid PEM encoding; must start with %s"
                         % PEM_HEADER)
    if not pem_cert_string.strip().endswith(PEM_FOOTER):
        raise ValueError("Invalid PEM encoding; must end with %s"
                         % PEM_FOOTER)
    d = pem_cert_string.strip()[len(PEM_HEADER):-len(PEM_FOOTER)]
    return base64.decodebytes(d.encode('ASCII', 'strict'))
def PEM_cert_to_DER_cert ( pem_cert_string ) : if not pem_cert_string . startswith ( PEM_HEADER ) : raise ValueError ( "Invalid PEM encoding; must start with %s" % PEM_HEADER ) if not pem_cert_string . strip ( ) . endswith ( PEM_FOOTER ) : raise ValueError ( "Invalid PEM encoding; must end with %s" % PEM_FOOTER ) d = pem_cert_string . strip ( ) [ len ( PEM_HEADER ) : - len ( PEM_FOOTER ) ] return base64 . decodebytes ( d . encode ( 'ASCII' , 'strict' ) )