Skip to content

Commit

Permalink
windows: import types directly
Browse files Browse the repository at this point in the history
  • Loading branch information
djc committed Aug 27, 2024
1 parent e2d4563 commit 0b8bd03
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
@@ -1,13 +1,15 @@
use std::io::Error;

use pki_types::CertificateDer;
use schannel::cert_context::ValidUses;
use schannel::cert_store::CertStore;

static PKIX_SERVER_AUTH: &str = "1.3.6.1.5.5.7.3.1";

fn usable_for_rustls(uses: schannel::cert_context::ValidUses) -> bool {
fn usable_for_rustls(uses: ValidUses) -> bool {
match uses {
schannel::cert_context::ValidUses::All => true,
schannel::cert_context::ValidUses::Oids(strs) => strs
ValidUses::All => true,
ValidUses::Oids(strs) => strs
.iter()
.any(|x| x == PKIX_SERVER_AUTH),
}
Expand All @@ -16,7 +18,7 @@ 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")?;
let current_user_store = CertStore::open_current_user("ROOT")?;

for cert in current_user_store.certs() {
if usable_for_rustls(cert.valid_uses().unwrap()) && cert.is_time_valid().unwrap() {
Expand Down

0 comments on commit 0b8bd03

Please sign in to comment.