Skip to content

Commit

Permalink
Windows: Also load intermediate CAs
Browse files Browse the repository at this point in the history
  • Loading branch information
amunra committed Nov 30, 2023
1 parent 3b0cc1b commit 8edf1f8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ fn usable_for_rustls(uses: schannel::cert_context::ValidUses) -> bool {
pub fn load_native_certs() -> Result<Vec<CertificateDer<'static>>, Error> {
let mut certs = Vec::new();

let current_user_store = schannel::cert_store::CertStore::open_current_user("ROOT")?;
for which in ["ROOT", "CA"] {
let current_user_store = schannel::cert_store::CertStore::open_current_user(which)?;

for cert in current_user_store.certs() {
if usable_for_rustls(cert.valid_uses().unwrap()) && cert.is_time_valid().unwrap() {
certs.push(CertificateDer::from(cert.to_der().to_vec()));
for cert in current_user_store.certs() {
if usable_for_rustls(cert.valid_uses().unwrap()) && cert.is_time_valid().unwrap() {
certs.push(CertificateDer::from(cert.to_der().to_vec()));
}
}
}

Expand Down

0 comments on commit 8edf1f8

Please sign in to comment.