Xbase++ Requires Chilkat v10.1.2+
Xbase++
Load PFX/P12 File into Certificate Store Object
Demonstrates how to load a .pfx/.p12 into a certificate store object.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oCertStore
LOCAL cPfxPassword
LOCAL oCert
LOCAL nNumCerts
LOCAL i
nSuccess := 0
oCertStore := CreateObject("Chilkat.CertStore")
// This only loads the contents of the PFX file into the certStore object.
// It is not importing the PFX into the Windows certificate stores.
cPfxPassword := "badssl.com"
nSuccess := oCertStore:LoadPfxFile("qa_data/pfx/badssl.com-client.p12", cPfxPassword)
IF (nSuccess == 0)
? oCertStore:LastErrorText
oCertStore:destroy()
RETURN
ENDIF
// Examine each certificate (loaded from the PFX) in this certStore object
oCert := CreateObject("Chilkat.Cert")
nNumCerts := oCertStore:NumCertificates
i := 0
DO WHILE i < nNumCerts
oCertStore:GetCert(i, oCert)
? "hasPrivateKey=" + Str(oCert:HasPrivateKey()) + ", " + oCert:SubjectCN
i := i + 1
ENDDO
oCertStore:destroy()
oCert:destroy()