Sample code for 30+ languages & platforms
Xbase++

Load P7B and List Certificates

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

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oPem
LOCAL i
LOCAL nNumCerts
LOCAL oCert

nSuccess := 0

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

nSuccess := 0

oPem := CreateObject("Chilkat.Pem")

//  Load the .p7b from a file.
nSuccess := oPem:LoadP7bFile("/Users/chilkat/testData/p7b/myCerts.p7b")
IF (nSuccess != 1)
    ? oPem:LastErrorText
    oPem:destroy()
    RETURN
ENDIF

nNumCerts := oPem:NumCerts
IF (nNumCerts == 0)
    ? ("Error: Expected the .p7b to contain certificates.")
    oPem:destroy()
    RETURN
ENDIF

//  Access each certificate and show the DN (Distinguished Name)
FOR i := 1 TO nNumCerts
    oCert := oPem:GetCert(i - 1)
    ? Str(i) + ": " + oCert:SubjectDN
    oCert:destroy()
NEXT

oPem:destroy()