Xbase++
Xbase++
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 Xbase++ Downloads
LOCAL nSuccess
LOCAL oPem
LOCAL nNumCrls
LOCAL i
LOCAL oAsn
LOCAL oXml
LOCAL cCrlBase64
nSuccess := 0
// 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.
oPem := CreateObject("Chilkat.Pem")
oPem:VerboseLogging := 1
nSuccess := oPem:LoadPemFile("qa_data/crl/sampleCrl.pem", "password_not_used")
IF (nSuccess != 1)
? oPem:LastErrorText
oPem:destroy()
RETURN
ENDIF
nNumCrls := oPem:NumCrls
i := 0
oAsn := CreateObject("Chilkat.Asn")
oXml := CreateObject("Chilkat.Xml")
DO WHILE i < nNumCrls
// Get the CRL as base64 (multi-line)
cCrlBase64 := oPem:GetEncodedItem("crl", "", "base64_mime", i)
IF (oPem:LastMethodSuccess != 1)
? oPem:LastErrorText
oPem:destroy()
oAsn:destroy()
oXml:destroy()
RETURN
ENDIF
? cCrlBase64
nSuccess := oAsn:LoadEncoded(cCrlBase64, "base64")
IF (nSuccess != 1)
? oAsn:LastErrorText
oPem:destroy()
oAsn:destroy()
oXml:destroy()
RETURN
ENDIF
// Convert ASN.1 to XML and load into xml and re-emit for pretty printing..
oXml:LoadXml(oAsn:AsnToXml())
? oXml:GetXml()
// Use this online tool to generate parsing code from CRL XML:
// Generate Parsing Code from XML
? "-------------------------------------"
i := i + 1
ENDDO
oPem:destroy()
oAsn:destroy()
oXml:destroy()