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 4
4
5
5
use rustls:: ClientConfig ;
6
6
use std:: sync:: Arc ;
7
+ use std:: time:: { Duration , SystemTime } ;
7
8
8
9
mod verification;
9
10
pub use verification:: Verifier ;
@@ -71,3 +72,12 @@ pub fn tls_config() -> ClientConfig {
71
72
pub fn verifier_for_dbg ( root : & [ u8 ] ) -> Arc < dyn rustls:: client:: ServerCertVerifier > {
72
73
Arc :: new ( Verifier :: new_with_fake_root ( root) )
73
74
}
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 23
23
use super :: TestCase ;
24
24
use crate :: tests:: assert_cert_error_eq;
25
25
use crate :: verification:: { EkuError , Verifier } ;
26
+ use crate :: verification_time;
26
27
use rustls:: { client:: ServerCertVerifier , CertificateError , Error as TlsError } ;
27
28
use std:: convert:: TryFrom ;
28
29
use std:: net:: IpAddr ;
@@ -95,7 +96,7 @@ pub(super) fn verification_without_mock_root() {
95
96
& server_name,
96
97
& mut std:: iter:: empty ( ) ,
97
98
& [ ] ,
98
- std :: time :: SystemTime :: now ( ) ,
99
+ verification_time ( ) ,
99
100
) ;
100
101
101
102
assert_eq ! (
@@ -289,7 +290,7 @@ fn test_with_mock_root<E: std::error::Error + PartialEq + 'static>(test_case: &T
289
290
& server_name,
290
291
& mut std:: iter:: empty ( ) ,
291
292
test_case. stapled_ocsp . unwrap_or ( & [ ] ) ,
292
- std :: time :: SystemTime :: now ( ) ,
293
+ verification_time ( ) ,
293
294
) ;
294
295
295
296
assert_cert_error_eq (
Original file line number Diff line number Diff line change 42
42
//! Thus we don't expect these tests to be flaky w.r.t. that, except for
43
43
//! potentially poor performance.
44
44
use super :: TestCase ;
45
- use crate :: { tests:: assert_cert_error_eq, Verifier } ;
45
+ use crate :: { tests:: assert_cert_error_eq, verification_time , Verifier } ;
46
46
use rustls:: { client:: ServerCertVerifier , CertificateError , Error as TlsError } ;
47
47
use std:: convert:: TryFrom ;
48
48
@@ -145,7 +145,7 @@ fn real_world_test<E: std::error::Error>(test_case: &TestCase<E>) {
145
145
& server_name,
146
146
& mut std:: iter:: empty ( ) ,
147
147
stapled_ocsp,
148
- std :: time :: SystemTime :: now ( ) ,
148
+ verification_time ( ) ,
149
149
)
150
150
. map ( |_| ( ) ) ;
151
151
You can’t perform that action at this time.
0 commit comments