Sample code for 30+ languages & platforms
Lianja

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 Lianja Downloads

Lianja
llSuccess = .F.

loCertStore = createobject("CkCertStore")

lcPfxPath = "/Users/chilkat/testData/pfx/chilkat_ssl.pfx"
lcPfxPassword = "test"
llSuccess = loCertStore.LoadPfxFile(lcPfxPath,lcPfxPassword)
if (llSuccess <> .T.) then
    ? loCertStore.LastErrorText
    release loCertStore
    return
endif

lnNumCerts = loCertStore.NumCertificates

? "PFX contains " + str(lnNumCerts) + " certificates"

loCert = createobject("CkCert")
i = 0
do while i < lnNumCerts
    loCertStore.GetCert(i,loCert)

    ? str(i) + ": (Common Name) " + loCert.SubjectCN
    ? str(i) + ": (Serial Number) " + loCert.SerialNumber
    ? str(i) + ": (Distinguished Name) " + loCert.SubjectDN

    i = i + 1
enddo


release loCertStore
release loCert