React Native
React Native
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 React Native Downloads
import { Asn, Pem, Xml } from '@chilkat/react-native'
function chilkatExample() {
// 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.
const pem = new Pem();
pem.verboseLogging = true;
try {
pem.loadPemFile('qa_data/crl/sampleCrl.pem', 'password_not_used');
} catch {
console.log(pem.lastErrorText);
return;
}
const numCrls = pem.numCrls;
let i = 0;
const asn = new Asn();
const xml = new Xml();
while (i < numCrls) {
// Get the CRL as base64 (multi-line)
let crlBase64: string;
try {
crlBase64 = pem.getEncodedItem('crl', '', 'base64_mime', i);
} catch {
console.log(pem.lastErrorText);
return;
}
console.log(crlBase64);
try {
asn.loadEncoded(crlBase64, 'base64');
} catch {
console.log(asn.lastErrorText);
return;
}
// Convert ASN.1 to XML and load into xml and re-emit for pretty printing..
xml.loadXml(asn.asnToXml());
console.log(xml.getXml());
// Use this online tool to generate parsing code from CRL XML:
// Generate Parsing Code from XML
console.log('-------------------------------------');
i++;
}
}