Rust
Rust
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 Rust Downloads
// 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.
let pem = chilkat::Pem::new();
pem.set_verbose_logging(true);
if pem.load_pem_file("qa_data/crl/sampleCrl.pem", "password_not_used").is_err() {
println!("{}", pem.last_error_text());
return;
}
let num_crls = pem.num_crls();
let mut i = 0;
let asn = chilkat::Asn::new();
let xml = chilkat::Xml::new();
while i < num_crls {
// Get the CRL as base64 (multi-line)
let Ok(crl_base64) = pem.get_encoded_item("crl", "", "base64_mime", i) else {
println!("{}", pem.last_error_text());
return;
};
println!("{}", crl_base64);
if asn.load_encoded(&crl_base64, "base64").is_err() {
println!("{}", asn.last_error_text());
return;
}
// Convert ASN.1 to XML and load into xml and re-emit for pretty printing..
let _ = xml.load_xml(&asn.asn_to_xml().unwrap_or_default());
println!("{}", xml.get_xml().unwrap_or_default());
// Use this online tool to generate parsing code from CRL XML:
// Generate Parsing Code from XML
println!("-------------------------------------");
i = i + 1;
}