Rust Requires Chilkat v10.1.2+
Rust
Load PFX/P12 File into Certificate Store Object
Demonstrates how to load a .pfx/.p12 into a certificate store object.Chilkat Rust Downloads
let cert_store = chilkat::CertStore::new();
// This only loads the contents of the PFX file into the certStore object.
// It is not importing the PFX into the Windows certificate stores.
let pfx_password = "badssl.com".to_string();
if cert_store.load_pfx_file("qa_data/pfx/badssl.com-client.p12", &pfx_password).is_err() {
println!("{}", cert_store.last_error_text());
return;
}
// Examine each certificate (loaded from the PFX) in this certStore object
let cert = chilkat::Cert::new();
let num_certs = cert_store.num_certificates();
let mut i = 0;
while i < num_certs {
let _ = cert_store.get_cert(i, &cert);
println!("hasPrivateKey={}, {}", cert.has_private_key(), cert.subject_cn());
i = i + 1;
}