Repository navigation
Conversation
Use the certificate identified by the Windows SSL policy and the time used to build the chain to distinguish expiration from a future start date. Retain the native error when the result cannot identify an out-of-date certificate. Cover both validity bounds on the leaf and evaluated intermediate, plus a valid path with an unused expired intermediate.
|
I'm still a little unclear on what problem you're actually trying to solve here? What is the observed output vs the expected output as a downstream user? |
|
On Windows, if a certificate in the chain isn't valid yet (say it was just issued and the client's clock is a few minutes behind), the verifier returns Expired. That's because Windows uses CERT_E_EXPIRED for both cases, too early and too late, and the crate maps it straight to Expired. webpki returns NotValidYet for the same chain. We show that error to our users. "Expired" sends them off to renew the server's certificate, when the real fix is the client's clock. I ran the new tests against current main (af209e4) on Windows 10: both the not-yet-valid leaf and the not-yet-valid intermediate come back as Expired. If checking each certificate's dates is more than you'd like here, the simpler fix is to drop the CERT_E_EXPIRED => Expired mapping and return the native error, like the macOS side does. The downside is that real expiry would no longer show up as Expired. |
Windows SSL chain policy reports
CERT_E_EXPIREDfor certificates outsideeither bound of their validity period. Use the chain and element indexes from
the policy result to check that certificate with
CertVerifyTimeValidityatthe same time used to build the chain. Return Rustls
ExpiredorNotValidYetwhen the check is conclusive and preserve the native errorwhen the policy result provides no usable element or direction.
macOS already avoids a misleading
Expiredby returning the native error,so this fix is scoped to Windows.
The Windows mock-root tests cover expired and not-yet-valid leaves and
evaluated intermediates, plus a valid path with an unused expired
intermediate supplied by the peer. The future intermediate case also
puts the unused expired certificate first in the peer's list of
intermediates. Each case runs with mock-only trust and with the extra-roots
fallback.
Verified with
cargo test,cargo clippy-ci, andcargo clippy-msrv-cion Windows x64.
Fixes #270