Sample code for 30+ languages & platforms
Rust Requires Chilkat v11.0.0+

Get Certificate Public Key from PEM

See more Certificates Examples

Demonstrates how to load a PEM file containing a certificate and access the public key.

Chilkat Rust Downloads

Rust

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

if cert.load_from_file("qa_data/pem/my_cert.pem").is_err() {
    println!("{}", cert.last_error_text());
    return;
}

let pubkey = chilkat::PublicKey::new();
let _ = cert.get_public_key(&pubkey);

// Examine the public key as XML..
println!("{}", pubkey.get_xml().unwrap_or_default());