Sample code for 30+ languages & platforms
CkPython

Load PFX (PKCS#12) and List Certificates

See more Certificates Examples

Loads a PFX file (.pfx, .p12) and iterates over the certificates found within.

Chilkat CkPython Downloads

CkPython
import sys
import chilkat

success = False

certStore = chilkat.CkCertStore()

pfxPath = "/Users/chilkat/testData/pfx/chilkat_ssl.pfx"
pfxPassword = "test"
success = certStore.LoadPfxFile(pfxPath,pfxPassword)
if (success != True):
    print(certStore.lastErrorText())
    sys.exit()

numCerts = certStore.get_NumCertificates()

print("PFX contains " + str(numCerts) + " certificates")

cert = chilkat.CkCert()
i = 0
while i < numCerts :
    certStore.GetCert(i,cert)

    print(str(i) + ": (Common Name) " + cert.subjectCN())
    print(str(i) + ": (Serial Number) " + cert.serialNumber())
    print(str(i) + ": (Distinguished Name) " + cert.subjectDN())

    i = i + 1