Perl Requires Chilkat v9.5.0.77+
Chilkat2 Perl
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.Chilkat Perl Downloads
use strict;
use warnings;
use Chilkat2;
# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
my $pem = Chilkat2::Pem->new;
$pem->VerboseLogging(1);
my $success = $pem->LoadPemFile('qa_data/crl/sampleCrl.pem', 'password_not_used');
if (!$success) {
print $pem->LastErrorText, "\n";
exit;
}
my $numCrls = $pem->NumCrls;
my $i = 0;
my $asn = Chilkat2::Asn->new;
my $xml = Chilkat2::Xml->new;
while ($i < $numCrls) {
# Get the CRL as base64 (multi-line)
my $crlBase64 = $pem->GetEncodedItem('crl', '', 'base64_mime', $i);
if (!$pem->LastMethodSuccess) {
print $pem->LastErrorText, "\n";
exit;
}
print $crlBase64, "\n";
$success = $asn->LoadEncoded($crlBase64, 'base64');
if (!$success) {
print $asn->LastErrorText, "\n";
exit;
}
# Convert ASN.1 to XML and load into xml and re-emit for pretty printing..
$xml->LoadXml($asn->AsnToXml());
print $xml->GetXml(), "\n";
# Use this online tool to generate parsing code from CRL XML:
# Generate Parsing Code from XML
print "-------------------------------------\n";
$i = $i + 1;
}