DataFlex
DataFlex
Convert CRL PEM to XML
See more PEM Examples
Loads a CRL (Certificate Revocation List) from the PEM file format and converts to XML to allow for visual examination and parsing.Note: This example requires Chilkat v9.5.0.77 or greater.
Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoPem
Integer iNumCrls
Integer i
Handle hoAsn
Handle hoXml
String sCrlBase64
String sTemp1
Boolean bTemp1
Move False To iSuccess
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// This example requires Chilkat v9.5.0.77 or greater.
Get Create (RefClass(cComChilkatPem)) To hoPem
If (Not(IsComObjectCreated(hoPem))) Begin
Send CreateComObject of hoPem
End
Set ComVerboseLogging Of hoPem To True
Get ComLoadPemFile Of hoPem "qa_data/crl/sampleCrl.pem" "password_not_used" To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoPem To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComNumCrls Of hoPem To iNumCrls
Move 0 To i
Get Create (RefClass(cComChilkatAsn)) To hoAsn
If (Not(IsComObjectCreated(hoAsn))) Begin
Send CreateComObject of hoAsn
End
Get Create (RefClass(cComChilkatXml)) To hoXml
If (Not(IsComObjectCreated(hoXml))) Begin
Send CreateComObject of hoXml
End
While (i < iNumCrls)
// Get the CRL as base64 (multi-line)
Get ComGetEncodedItem Of hoPem "crl" "" "base64_mime" i To sCrlBase64
Get ComLastMethodSuccess Of hoPem To bTemp1
If (bTemp1 <> True) Begin
Get ComLastErrorText Of hoPem To sTemp1
Showln sTemp1
Procedure_Return
End
Showln sCrlBase64
Get ComLoadEncoded Of hoAsn sCrlBase64 "base64" To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoAsn To sTemp1
Showln sTemp1
Procedure_Return
End
// Convert ASN.1 to XML and load into xml and re-emit for pretty printing..
Get ComAsnToXml Of hoAsn To sTemp1
Get ComLoadXml Of hoXml sTemp1 To iSuccess
Get ComGetXml Of hoXml To sTemp1
Showln sTemp1
// Use this online tool to generate parsing code from CRL XML:
// Generate Parsing Code from XML
Showln "-------------------------------------"
Move (i + 1) To i
Loop
End_Procedure