DataFlex
DataFlex
Load P7B and Iterate Certificates
See more PEM Examples
Demonstrates how to load a .p7b containing one or more certificates access each of them.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoPem
Integer iNumCerts
Integer i
Variant vCert
Handle hoCert
String sTemp1
Move False To iSuccess
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Move False To iSuccess
// The Chilkat PEM class was introduced in v9.5.0.49.
// It requires the bundle to be unlocked, as shown above.
Get Create (RefClass(cComChilkatPem)) To hoPem
If (Not(IsComObjectCreated(hoPem))) Begin
Send CreateComObject of hoPem
End
// Load the .p7b from a file.
Get ComLoadP7bFile Of hoPem "../myCertFiles/myP7b.p7b" To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoPem To sTemp1
Showln sTemp1
Procedure_Return
End
// Note: If the app already has the p7b loaded in memory, the LoadP7b method
// may be called instead. (see the online reference documentation)
// Iterate over the certificates.
Get ComNumCerts Of hoPem To iNumCerts
Move 0 To i
While (i < iNumCerts)
Get ComGetCert Of hoPem i To vCert
If (IsComObject(vCert)) Begin
Get Create (RefClass(cComChilkatCert)) To hoCert
Set pvComObject Of hoCert To vCert
End
Get ComSubjectDN Of hoCert To sTemp1
Showln "Certificate " i " : " sTemp1
Send Destroy of hoCert
Move (i + 1) To i
Loop
End_Procedure