Sample code for 30+ languages & platforms
Visual FoxPro

Load P7B and List Certificates

Demonstrates how to load a .p7b containing certificates and accesses each individual certificate.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loPem
LOCAL i
LOCAL lnNumCerts
LOCAL loCert

lnSuccess = 0

* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.

lnSuccess = 0

loPem = CreateObject('Chilkat.Pem')

* Load the .p7b from a file.
lnSuccess = loPem.LoadP7bFile("/Users/chilkat/testData/p7b/myCerts.p7b")
IF (lnSuccess <> 1) THEN
    ? loPem.LastErrorText
    RELEASE loPem
    CANCEL
ENDIF

lnNumCerts = loPem.NumCerts
IF (lnNumCerts = 0) THEN
    ? ("Error: Expected the .p7b to contain certificates.")
    RELEASE loPem
    CANCEL
ENDIF

* Access each certificate and show the DN (Distinguished Name)
FOR i = 1 TO lnNumCerts
    loCert = loPem.GetCert(i - 1)
    ? STR(i) + ": " + loCert.SubjectDN
    RELEASE loCert
NEXT

RELEASE loPem