Lianja
Lianja
Load PEM and List Certificates
Demonstrates how to load a PEM containing certificates and accesses each individual certificate.Chilkat Lianja Downloads
llSuccess = .F.
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
llSuccess = .F.
loPem = createobject("CkPem")
// Load the .p7b from a file.
llSuccess = loPem.LoadPemFile("/Users/chilkat/testData/p7b/cacert_mozilla.pem")
if (llSuccess <> .T.) then
? loPem.LastErrorText
release loPem
return
endif
lnNumCerts = loPem.NumCerts
if (lnNumCerts = 0) then
? ("Error: Expected the PEM to contain certificates.")
release loPem
return
endif
// Access each certificate and show the Subject CN (Common Name)
for i = 1 to lnNumCerts
loCert = loPem.GetCert(i - 1)
? str(i) + ": " + loCert.SubjectCN
release loCert
next
release loPem