Sample code for 30+ languages & platforms
Rust

Get Certificate CRL Distribution Points

See more Certificates Examples

Demonstrates how to get a certificate's CRL Distribution Points extension data (assuming it exists). In the vast majority of cases, there will be one CRL Distribution Point.

Note: This example requires Chilkat v9.5.0.76 or greater.

Chilkat Rust Downloads

Rust

let cert = chilkat::Cert::new();

if cert.load_from_file("qa_data/certs/test_haswdt.cer").is_err() {
    println!("{}", cert.last_error_text());
    return;
}

// Get the CRL Distribution Points extension, which is at OID 2.5.29.31
let Ok(extension_xml_str) = cert.get_extension_as_xml("2.5.29.31") else {
    println!("Certificate does not have the CDP extension.");
    return;
};

let xml = chilkat::Xml::new();
let _ = xml.load_xml(&extension_xml_str);

// See what we have..
println!("{}", xml.get_xml().unwrap_or_default());

// We should get XML like this:

// <?xml version="1.0" encoding="utf-8" ?>
// <sequence>
//     <sequence>
//         <contextSpecific tag="0" constructed="1">
//             <contextSpecific tag="0" constructed="1">
//                 <contextSpecific tag="6" constructed="0">aHR0cDovL2NybC5jb21vZG9jYS5jb20vQ09NT0RPUlNBQ2xpZW50QXV0aGVudGljYXRpb25hbmRTZWN1
// cmVFbWFpbENBLmNybA==</contextSpecific>
//             </contextSpecific>
//         </contextSpecific>
//     </sequence>
// </sequence>
// 

// Assuming there is one CRL Distribution Point...
let sb_dist_point = chilkat::StringBuilder::new();
if xml.get_child_content_sb("sequence|contextSpecific|contextSpecific|contextSpecific", &sb_dist_point).is_ok() {
    let _ = sb_dist_point.decode("base64", "utf-8");
    println!("CRL Distribution Point:  {}", sb_dist_point.get_as_string().unwrap_or_default());
}

// Sample output:
// CRL Distribution Point:  http://crl.comodoca.com/COMODORSAClientAuthenticationandSecureEmailCA.crl