def x509_parse_cert(cert, binary=False):
 if binary:
  bio = BIO.MemoryBuffer(cert)
  x509 = X509.load_cert_bio(bio, X509.FORMAT_DER)
 elif cert.startswith('-----BEGIN CERTIFICATE-----'):
  bio = BIO.MemoryBuffer(cert)
  x509 = X509.load_cert_bio(bio, X509.FORMAT_PEM)
 else:
  x509 = X509.load_cert(cert, 1)
 return x509

def x509_parse_cert ( cert , binary = False ) : if binary : bio = BIO . MemoryBuffer ( cert ) x509 = X509 . load_cert_bio ( bio , X509 . FORMAT_DER ) elif cert . startswith ( '-----BEGIN CERTIFICATE-----' ) : bio = BIO . MemoryBuffer ( cert ) x509 = X509 . load_cert_bio ( bio , X509 . FORMAT_PEM ) else : x509 = X509 . load_cert ( cert , 1 ) return x509
create a x509 certificate from binary der .