Dart
Dart
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 Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
// 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.
final pem = CkPem();
pem.verboseLogging = true;
try {
pem.loadPemFile('qa_data/crl/sampleCrl.pem', 'password_not_used');
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
final numCrls = pem.numCrls;
var i = 0;
final asn = CkAsn();
final xml = CkXml();
while (i < numCrls) {
// Get the CRL as base64 (multi-line)
final String crlBase64;
try {
crlBase64 = pem.getEncodedItem('crl', '', 'base64_mime', i);
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
print(crlBase64);
try {
asn.loadEncoded(crlBase64, 'base64');
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
// Convert ASN.1 to XML and load into xml and re-emit for pretty printing..
xml.loadXml(asn.asnToXml());
print(xml.getXml());
// Use this online tool to generate parsing code from CRL XML:
// Generate Parsing Code from XML
print('-------------------------------------');
i++;
}
}