2121) ) ]
2222
2323use super :: TestCase ;
24- use crate :: tests:: assert_cert_error_eq;
24+ use crate :: tests:: { assert_cert_error_eq, verification_time } ;
2525use crate :: verification:: { EkuError , Verifier } ;
2626use rustls:: { client:: ServerCertVerifier , CertificateError , Error as TlsError } ;
2727use std:: convert:: TryFrom ;
@@ -95,7 +95,7 @@ pub(super) fn verification_without_mock_root() {
9595 & server_name,
9696 & mut std:: iter:: empty ( ) ,
9797 & [ ] ,
98- std :: time :: SystemTime :: now ( ) ,
98+ verification_time ( ) ,
9999 ) ;
100100
101101 assert_eq ! (
@@ -120,41 +120,47 @@ mock_root_test_cases! {
120120 reference_id: EXAMPLE_COM ,
121121 chain: & [ ROOT1_INT1_EXAMPLE_COM_GOOD , ROOT1_INT1 ] ,
122122 stapled_ocsp: None ,
123+ verification_time: verification_time( ) ,
123124 expected_result: Ok ( ( ) ) ,
124125 other_error: no_error!( ) ,
125126 } ,
126127 valid_no_stapling_ipv4 [ any( windows, target_os = "android" , target_os = "macos" , target_os = "linux" ) ] => TestCase {
127128 reference_id: LOCALHOST_IPV4 ,
128129 chain: & [ ROOT1_INT1_LOCALHOST_IPV4_GOOD , ROOT1_INT1 ] ,
129130 stapled_ocsp: None ,
131+ verification_time: verification_time( ) ,
130132 expected_result: Ok ( ( ) ) ,
131133 other_error: no_error!( ) ,
132134 } ,
133135 valid_no_stapling_ipv6 [ any( windows, target_os = "android" , target_os = "macos" , target_os = "linux" ) ] => TestCase {
134136 reference_id: LOCALHOST_IPV6 ,
135137 chain: & [ ROOT1_INT1_LOCALHOST_IPV6_GOOD , ROOT1_INT1 ] ,
136138 stapled_ocsp: None ,
139+ verification_time: verification_time( ) ,
137140 expected_result: Ok ( ( ) ) ,
138141 other_error: no_error!( ) ,
139142 } ,
140143 valid_stapled_good_dns [ any( windows, target_os = "android" , target_os = "android" , target_os = "macos" , target_os = "linux" ) ] => TestCase {
141144 reference_id: EXAMPLE_COM ,
142145 chain: & [ ROOT1_INT1_EXAMPLE_COM_GOOD , ROOT1_INT1 ] ,
143146 stapled_ocsp: Some ( include_bytes!( "root1-int1-ee_example.com-good.ocsp" ) ) ,
147+ verification_time: verification_time( ) ,
144148 expected_result: Ok ( ( ) ) ,
145149 other_error: no_error!( ) ,
146150 } ,
147151 valid_stapled_good_ipv4 [ any( windows, target_os = "android" , target_os = "macos" , target_os = "linux" ) ] => TestCase {
148152 reference_id: LOCALHOST_IPV4 ,
149153 chain: & [ ROOT1_INT1_LOCALHOST_IPV4_GOOD , ROOT1_INT1 ] ,
150154 stapled_ocsp: Some ( include_bytes!( "root1-int1-ee_127.0.0.1-good.ocsp" ) ) ,
155+ verification_time: verification_time( ) ,
151156 expected_result: Ok ( ( ) ) ,
152157 other_error: no_error!( ) ,
153158 } ,
154159 valid_stapled_good_ipv6 [ any( windows, target_os = "android" , target_os = "macos" , target_os = "linux" ) ] => TestCase {
155160 reference_id: LOCALHOST_IPV6 ,
156161 chain: & [ ROOT1_INT1_LOCALHOST_IPV6_GOOD , ROOT1_INT1 ] ,
157162 stapled_ocsp: Some ( include_bytes!( "root1-int1-ee_1-good.ocsp" ) ) ,
163+ verification_time: verification_time( ) ,
158164 expected_result: Ok ( ( ) ) ,
159165 other_error: no_error!( ) ,
160166 } ,
@@ -166,20 +172,23 @@ mock_root_test_cases! {
166172 reference_id: EXAMPLE_COM ,
167173 chain: & [ include_bytes!( "root1-int1-ee_example.com-revoked.crt" ) , ROOT1_INT1 ] ,
168174 stapled_ocsp: Some ( include_bytes!( "root1-int1-ee_example.com-revoked.ocsp" ) ) ,
175+ verification_time: verification_time( ) ,
169176 expected_result: Err ( TlsError :: InvalidCertificate ( CertificateError :: Revoked ) ) ,
170177 other_error: no_error!( ) ,
171178 } ,
172179 stapled_revoked_ipv4 [ any( windows, target_os = "android" , target_os = "macos" ) ] => TestCase {
173180 reference_id: LOCALHOST_IPV4 ,
174181 chain: & [ include_bytes!( "root1-int1-ee_127.0.0.1-revoked.crt" ) , ROOT1_INT1 ] ,
175182 stapled_ocsp: Some ( include_bytes!( "root1-int1-ee_127.0.0.1-revoked.ocsp" ) ) ,
183+ verification_time: verification_time( ) ,
176184 expected_result: Err ( TlsError :: InvalidCertificate ( CertificateError :: Revoked ) ) ,
177185 other_error: no_error!( ) ,
178186 } ,
179187 stapled_revoked_ipv6 [ any( windows, target_os = "android" , target_os = "macos" ) ] => TestCase {
180188 reference_id: LOCALHOST_IPV6 ,
181189 chain: & [ include_bytes!( "root1-int1-ee_1-revoked.crt" ) , ROOT1_INT1 ] ,
182190 stapled_ocsp: Some ( include_bytes!( "root1-int1-ee_1-revoked.ocsp" ) ) ,
191+ verification_time: verification_time( ) ,
183192 expected_result: Err ( TlsError :: InvalidCertificate ( CertificateError :: Revoked ) ) ,
184193 other_error: no_error!( ) ,
185194 } ,
@@ -192,20 +201,23 @@ mock_root_test_cases! {
192201 reference_id: EXAMPLE_COM ,
193202 chain: & [ ROOT1_INT1_EXAMPLE_COM_GOOD ] ,
194203 stapled_ocsp: None ,
204+ verification_time: verification_time( ) ,
195205 expected_result: Err ( TlsError :: InvalidCertificate ( CertificateError :: UnknownIssuer ) ) ,
196206 other_error: no_error!( ) ,
197207 } ,
198208 ee_only_ipv4 [ any( windows, target_os = "android" , target_os = "macos" , target_os = "linux" ) ] => TestCase {
199209 reference_id: LOCALHOST_IPV4 ,
200210 chain: & [ ROOT1_INT1_LOCALHOST_IPV4_GOOD ] ,
201211 stapled_ocsp: None ,
212+ verification_time: verification_time( ) ,
202213 expected_result: Err ( TlsError :: InvalidCertificate ( CertificateError :: UnknownIssuer ) ) ,
203214 other_error: no_error!( ) ,
204215 } ,
205216 ee_only_ipv6 [ any( windows, target_os = "android" , target_os = "macos" , target_os = "linux" ) ] => TestCase {
206217 reference_id: LOCALHOST_IPV6 ,
207218 chain: & [ ROOT1_INT1_LOCALHOST_IPV6_GOOD ] ,
208219 stapled_ocsp: None ,
220+ verification_time: verification_time( ) ,
209221 expected_result: Err ( TlsError :: InvalidCertificate ( CertificateError :: UnknownIssuer ) ) ,
210222 other_error: no_error!( ) ,
211223 } ,
@@ -214,27 +226,31 @@ mock_root_test_cases! {
214226 reference_id: "example.org" ,
215227 chain: & [ ROOT1_INT1_EXAMPLE_COM_GOOD , ROOT1_INT1 ] ,
216228 stapled_ocsp: None ,
229+ verification_time: verification_time( ) ,
217230 expected_result: Err ( TlsError :: InvalidCertificate ( CertificateError :: NotValidForName ) ) ,
218231 other_error: no_error!( ) ,
219232 } ,
220233 domain_mismatch_ipv4 [ any( windows, target_os = "android" , target_os = "macos" , target_os = "linux" ) ] => TestCase {
221234 reference_id: "198.168.0.1" ,
222235 chain: & [ ROOT1_INT1_LOCALHOST_IPV4_GOOD , ROOT1_INT1 ] ,
223236 stapled_ocsp: None ,
237+ verification_time: verification_time( ) ,
224238 expected_result: Err ( TlsError :: InvalidCertificate ( CertificateError :: NotValidForName ) ) ,
225239 other_error: no_error!( ) ,
226240 } ,
227241 domain_mismatch_ipv6 [ any( windows, target_os = "android" , target_os = "macos" , target_os = "linux" ) ] => TestCase {
228242 reference_id: "::ffff:c6a8:1" ,
229243 chain: & [ ROOT1_INT1_LOCALHOST_IPV6_GOOD , ROOT1_INT1 ] ,
230244 stapled_ocsp: None ,
245+ verification_time: verification_time( ) ,
231246 expected_result: Err ( TlsError :: InvalidCertificate ( CertificateError :: NotValidForName ) ) ,
232247 other_error: no_error!( ) ,
233248 } ,
234249 wrong_eku_dns [ any( windows, target_os = "android" , target_os = "macos" , target_os = "linux" ) ] => TestCase {
235250 reference_id: EXAMPLE_COM ,
236251 chain: & [ include_bytes!( "root1-int1-ee_example.com-wrong_eku.crt" ) , ROOT1_INT1 ] ,
237252 stapled_ocsp: None ,
253+ verification_time: verification_time( ) ,
238254 expected_result: Err ( TlsError :: InvalidCertificate (
239255 CertificateError :: Other ( Arc :: from( EkuError ) ) ) ) ,
240256 other_error: Some ( EkuError ) ,
@@ -243,6 +259,7 @@ mock_root_test_cases! {
243259 reference_id: LOCALHOST_IPV4 ,
244260 chain: & [ include_bytes!( "root1-int1-ee_127.0.0.1-wrong_eku.crt" ) , ROOT1_INT1 ] ,
245261 stapled_ocsp: None ,
262+ verification_time: verification_time( ) ,
246263 expected_result: Err ( TlsError :: InvalidCertificate (
247264 CertificateError :: Other ( Arc :: from( EkuError ) ) ) ) ,
248265 other_error: Some ( EkuError ) ,
@@ -251,6 +268,7 @@ mock_root_test_cases! {
251268 reference_id: LOCALHOST_IPV6 ,
252269 chain: & [ include_bytes!( "root1-int1-ee_1-wrong_eku.crt" ) , ROOT1_INT1 ] ,
253270 stapled_ocsp: None ,
271+ verification_time: verification_time( ) ,
254272 expected_result: Err ( TlsError :: InvalidCertificate (
255273 CertificateError :: Other ( Arc :: from( EkuError ) ) ) ) ,
256274 other_error: Some ( EkuError ) ,
@@ -289,7 +307,7 @@ fn test_with_mock_root<E: std::error::Error + PartialEq + 'static>(test_case: &T
289307 & server_name,
290308 & mut std:: iter:: empty ( ) ,
291309 test_case. stapled_ocsp . unwrap_or ( & [ ] ) ,
292- std :: time :: SystemTime :: now ( ) ,
310+ test_case . verification_time ,
293311 ) ;
294312
295313 assert_cert_error_eq (
0 commit comments