Rust
Rust
Iterate over Certificates on Connected Smart Cards and USB Tokens
See more Cert Store Examples
Demonstrates how to iterate over the certificates on connected smart cards and USB tokens.Note: Requires Chilkat v10.1.2 or later.
Chilkat Rust Downloads
let cert_store = chilkat::CertStore::new();
// Detects connected smart cards and USB tokens
// and loads the certificate store object with the certificates found.
// Works on Windows, MacOS, iOS, and Linux.
// Note: If something is not detected, contact info@chilkatsoft.com
// for help or for workarounds.
let arg_not_used = String::new();
if cert_store.open_smartcard(&arg_not_used).is_err() {
println!("{}", cert_store.last_error_text());
return;
}
let cert = chilkat::Cert::new();
let num_certs = cert_store.num_certificates();
let mut i = 0;
while i < num_certs {
// Load the cert object with the Nth certificate found in the connected HSMs
let _ = cert_store.get_cert(i, &cert);
println!("{}: {}", i, cert.subject_cn());
i = i + 1;
}