PowerBuilder
PowerBuilder
Load PEM and List Certificates
Demonstrates how to load a PEM containing certificates and accesses each individual certificate.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Pem
integer i
integer li_NumCerts
oleobject loo_Cert
li_Success = 0
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
li_Success = 0
loo_Pem = create oleobject
li_rc = loo_Pem.ConnectToNewObject("Chilkat.Pem")
if li_rc < 0 then
destroy loo_Pem
MessageBox("Error","Connecting to COM object failed")
return
end if
// Load the .p7b from a file.
li_Success = loo_Pem.LoadPemFile("/Users/chilkat/testData/p7b/cacert_mozilla.pem")
if li_Success <> 1 then
Write-Debug loo_Pem.LastErrorText
destroy loo_Pem
return
end if
li_NumCerts = loo_Pem.NumCerts
if li_NumCerts = 0 then
Write-Debug ("Error: Expected the PEM to contain certificates.")
destroy loo_Pem
return
end if
// Access each certificate and show the Subject CN (Common Name)
for i = 1 to li_NumCerts
loo_Cert = loo_Pem.GetCert(i - 1)
Write-Debug string(i) + ": " + loo_Cert.SubjectCN
destroy loo_Cert
next
destroy loo_Pem