@@ -49,8 +49,9 @@ use windows_sys::Win32::{
4949 CERT_CHAIN_REVOCATION_ACCUMULATIVE_TIMEOUT , CERT_CHAIN_REVOCATION_CHECK_END_CERT ,
5050 CERT_CONTEXT , CERT_OCSP_RESPONSE_PROP_ID , CERT_SET_PROPERTY_IGNORE_PERSIST_ERROR_FLAG ,
5151 CERT_STORE_ADD_ALWAYS , CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG , CERT_STORE_PROV_MEMORY ,
52- CERT_STRONG_SIGN_PARA , CERT_TRUST_IS_PARTIAL_CHAIN , CERT_USAGE_MATCH , CRYPT_INTEGER_BLOB ,
53- CTL_USAGE , HCERTSTORE , USAGE_MATCH_TYPE_AND , X509_ASN_ENCODING ,
52+ CERT_STRONG_SIGN_PARA , CERT_TRUST_IS_PARTIAL_CHAIN , CERT_TRUST_IS_UNTRUSTED_ROOT ,
53+ CERT_USAGE_MATCH , CRYPT_INTEGER_BLOB , CTL_USAGE , HCERTSTORE , USAGE_MATCH_TYPE_AND ,
54+ X509_ASN_ENCODING ,
5455 } ,
5556} ;
5657
@@ -648,15 +649,16 @@ impl Verifier {
648649
649650 // We only use `TrustStatus` here because it hasn't had verification performed on it.
650651 // SAFETY: The pointer is guaranteed to be non-null.
651- let is_partial_chain = unsafe { * cert_chain. inner . as_ptr ( ) }
652+ let cert_error_status = unsafe { * cert_chain. inner . as_ptr ( ) }
652653 . TrustStatus
653- . dwErrorStatus
654- & CERT_TRUST_IS_PARTIAL_CHAIN
655- != 0 ;
654+ . dwErrorStatus ;
655+
656+ let extra_roots_may_needed =
657+ ( cert_error_status & ( CERT_TRUST_IS_PARTIAL_CHAIN | CERT_TRUST_IS_UNTRUSTED_ROOT ) ) != 0 ;
656658
657659 // If we have extra roots and building the chain gave us an error, we try to build a
658660 // new one with the extra roots.
659- if is_partial_chain && self . extra_roots . is_some ( ) {
661+ if extra_roots_may_needed && self . extra_roots . is_some ( ) {
660662 let mut store = CertificateStore :: new ( ) ?;
661663
662664 for cert in intermediate_certs. iter ( ) . copied ( ) {
0 commit comments