@@ -36,7 +36,7 @@ use winapi::{
36
36
CertAddEncodedCertificateToStore , CertCloseStore , CertFreeCertificateChain ,
37
37
CertFreeCertificateChainEngine , CertFreeCertificateContext , CertGetCertificateChain ,
38
38
CertOpenStore , CertSetCertificateContextProperty , CertVerifyCertificateChainPolicy ,
39
- AUTHTYPE_SERVER , CERT_CHAIN_CONTEXT , CERT_CHAIN_PARA ,
39
+ AUTHTYPE_SERVER , CERT_CHAIN_CACHE_END_CERT , CERT_CHAIN_CONTEXT , CERT_CHAIN_PARA ,
40
40
CERT_CHAIN_POLICY_IGNORE_ALL_REV_UNKNOWN_FLAGS , CERT_CHAIN_POLICY_PARA ,
41
41
CERT_CHAIN_POLICY_SSL , CERT_CHAIN_POLICY_STATUS ,
42
42
CERT_CHAIN_REVOCATION_ACCUMULATIVE_TIMEOUT , CERT_CHAIN_REVOCATION_CHECK_END_CERT ,
@@ -367,11 +367,14 @@ impl CertificateStore {
367
367
}
368
368
} ;
369
369
370
- // `CERT_CHAIN_REVOCATION_CHECK_END_CERT` only checks revocation for end cert.
370
+ // `CERT_CHAIN_REVOCATION_CHECK_END_CERT` only checks revocation for end cert. See the crate's revocation documentation
371
+ // for more details.
371
372
// `CERT_CHAIN_REVOCATION_ACCUMULATIVE_TIMEOUT` accumulates network retrievals timeouts
372
373
// to limit network time and improve performance.
373
- const FLAGS : u32 =
374
- CERT_CHAIN_REVOCATION_CHECK_END_CERT | CERT_CHAIN_REVOCATION_ACCUMULATIVE_TIMEOUT ;
374
+ // `CERT_CHAIN_CACHE_END_CERT` speeds up the common case of multiple connections to same server.
375
+ const FLAGS : u32 = CERT_CHAIN_REVOCATION_CHECK_END_CERT
376
+ | CERT_CHAIN_REVOCATION_ACCUMULATIVE_TIMEOUT
377
+ | CERT_CHAIN_CACHE_END_CERT ;
375
378
376
379
// Lowering URL retrieval timeout from default 15s to 10s to account for higher internet speeds
377
380
parameters. dwUrlRetrievalTimeout = 10 * 1000 ; // milliseconds
@@ -391,12 +394,12 @@ impl CertificateStore {
391
394
)
392
395
} ;
393
396
394
- let cert_chain = call_with_last_error ( || match nonnull_from_const_ptr ( cert_chain) {
395
- Some ( c) if res == TRUE => Some ( c) ,
397
+ // XXX: Windows will internally map the chain's `TrustStatus.dwErrorStatus` to a `dwError` when
398
+ // a chain policy is verified, so we only check for errors there.
399
+ call_with_last_error ( || match nonnull_from_const_ptr ( cert_chain) {
400
+ Some ( c) if res == TRUE => Some ( CertChain { inner : c } ) ,
396
401
_ => None ,
397
- } ) ?;
398
-
399
- Ok ( CertChain { inner : cert_chain } )
402
+ } )
400
403
}
401
404
}
402
405
0 commit comments