Xbase++
Xbase++
Load PEM and List Certificates
Demonstrates how to load a PEM containing certificates and accesses each individual certificate.Chilkat Xbase++ Downloads
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:LoadPemFile("/Users/chilkat/testData/p7b/cacert_mozilla.pem")
IF (nSuccess != 1)
? oPem:LastErrorText
oPem:destroy()
RETURN
ENDIF
nNumCerts := oPem:NumCerts
IF (nNumCerts == 0)
? ("Error: Expected the PEM to contain certificates.")
oPem:destroy()
RETURN
ENDIF
// Access each certificate and show the Subject CN (Common Name)
FOR i := 1 TO nNumCerts
oCert := oPem:GetCert(i - 1)
? Str(i) + ": " + oCert:SubjectCN
oCert:destroy()
NEXT
oPem:destroy()