Sample code for 30+ languages & platforms
Visual FoxPro

Load PFX/P12 File into Certificate Store Object

Demonstrates how to load a .pfx/.p12 into a certificate store object.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loCertStore
LOCAL lcPfxPassword
LOCAL loCert
LOCAL lnNumCerts
LOCAL i

lnSuccess = 0

loCertStore = 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.
lcPfxPassword = "badssl.com"
lnSuccess = loCertStore.LoadPfxFile("qa_data/pfx/badssl.com-client.p12",lcPfxPassword)
IF (lnSuccess = 0) THEN
    ? loCertStore.LastErrorText
    RELEASE loCertStore
    CANCEL
ENDIF

* Examine each certificate (loaded from the PFX) in this certStore object
loCert = CreateObject('Chilkat.Cert')
lnNumCerts = loCertStore.NumCertificates
i = 0
DO WHILE i < lnNumCerts
    loCertStore.GetCert(i,loCert)
    ? "hasPrivateKey=" + STR(loCert.HasPrivateKey()) + ", " + loCert.SubjectCN
    i = i + 1
ENDDO

RELEASE loCertStore
RELEASE loCert