File tree Expand file tree Collapse file tree 3 files changed +15
-4
lines changed
rustls-platform-verifier/src Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 44
55use rustls:: ClientConfig ;
66use std:: sync:: Arc ;
7+ use std:: time:: { Duration , SystemTime } ;
78
89mod verification;
910pub use verification:: Verifier ;
@@ -71,3 +72,12 @@ pub fn tls_config() -> ClientConfig {
7172pub fn verifier_for_dbg ( root : & [ u8 ] ) -> Arc < dyn rustls:: client:: ServerCertVerifier > {
7273 Arc :: new ( Verifier :: new_with_fake_root ( root) )
7374}
75+
76+ /// Return a fixed [SystemTime] for certificate validation purposes.
77+ ///
78+ /// We fix the "now" value used for certificate validation to a fixed point in time at which
79+ /// we know the test certificates are valid. This must be updated if the test certificates
80+ /// are regenerated.
81+ pub fn verification_time ( ) -> SystemTime {
82+ SystemTime :: UNIX_EPOCH + Duration :: from_secs ( 1_704_304_988 )
83+ }
Original file line number Diff line number Diff line change 2323use super :: TestCase ;
2424use crate :: tests:: assert_cert_error_eq;
2525use crate :: verification:: { EkuError , Verifier } ;
26+ use crate :: verification_time;
2627use rustls:: { client:: ServerCertVerifier , CertificateError , Error as TlsError } ;
2728use std:: convert:: TryFrom ;
2829use std:: net:: IpAddr ;
@@ -95,7 +96,7 @@ pub(super) fn verification_without_mock_root() {
9596 & server_name,
9697 & mut std:: iter:: empty ( ) ,
9798 & [ ] ,
98- std :: time :: SystemTime :: now ( ) ,
99+ verification_time ( ) ,
99100 ) ;
100101
101102 assert_eq ! (
@@ -289,7 +290,7 @@ fn test_with_mock_root<E: std::error::Error + PartialEq + 'static>(test_case: &T
289290 & server_name,
290291 & mut std:: iter:: empty ( ) ,
291292 test_case. stapled_ocsp . unwrap_or ( & [ ] ) ,
292- std :: time :: SystemTime :: now ( ) ,
293+ verification_time ( ) ,
293294 ) ;
294295
295296 assert_cert_error_eq (
Original file line number Diff line number Diff line change 4242//! Thus we don't expect these tests to be flaky w.r.t. that, except for
4343//! potentially poor performance.
4444use super :: TestCase ;
45- use crate :: { tests:: assert_cert_error_eq, Verifier } ;
45+ use crate :: { tests:: assert_cert_error_eq, verification_time , Verifier } ;
4646use rustls:: { client:: ServerCertVerifier , CertificateError , Error as TlsError } ;
4747use std:: convert:: TryFrom ;
4848
@@ -145,7 +145,7 @@ fn real_world_test<E: std::error::Error>(test_case: &TestCase<E>) {
145145 & server_name,
146146 & mut std:: iter:: empty ( ) ,
147147 stapled_ocsp,
148- std :: time :: SystemTime :: now ( ) ,
148+ verification_time ( ) ,
149149 )
150150 . map ( |_| ( ) ) ;
151151
You can’t perform that action at this time.
0 commit comments