Sample code for 30+ languages & platforms
Chilkat2-Python

Load DER encoded X.509 Certificate (.cer, .crt)

See more Certificates Examples

Loads a digital certificate from a binary DER encoded X.509 Certificate (.cer, .crt) and fetches information about the cert.

Chilkat Chilkat2-Python Downloads

Chilkat2-Python
import sys
import chilkat2

success = False

cert = chilkat2.Cert()

# LoadFromFile will load virtually any certificate format file.
# It will auto-recognize the format and load appropiately.
success = cert.LoadFromFile("/Users/chilkat/testData/cer/chilkat_ssl.cer")
if (success != True):
    print(cert.LastErrorText)
    sys.exit()

# DN = "Distinguished Name"
print("SubjectDN:" + cert.SubjectDN)

print("Common Name:" + cert.SubjectCN)
print("Issuer Common Name:" + cert.IssuerCN)

print("Serial Number:" + cert.SerialNumber)