Rust
Rust
Import a Certificate (.cer file) into a Windows Certificate Store
See more Certificates Examples
Demonstrates how to import a certificate (without private key) into a Windows certificate store.Chilkat Rust Downloads
let cert = chilkat::Cert::new();
if cert.load_from_file("qa_data/certs/example.cer").is_err() {
println!("{}", cert.last_error_text());
return;
}
let cert_store_cu = chilkat::CertStore::new();
let read_only_flag = false;
// "CurrentUser" and "My" are the exact keywords to select your user account's certificate store.
if cert_store_cu.open_windows_store("CurrentUser", "My", read_only_flag).is_err() {
println!("Failed to open the CurrentUser/My certificate store for read/write.");
return;
}
// Import the certificate into the CurrentUser/My certificate store.
if cert_store_cu.add_certificate(&cert).is_err() {
println!("{}", cert_store_cu.last_error_text());
return;
}
println!("Imported {}", cert.subject_cn());
println!("Success.");