21
21
) ) ]
22
22
23
23
use super :: TestCase ;
24
- use crate :: tests:: assert_cert_error_eq;
24
+ use crate :: tests:: { assert_cert_error_eq, verification_time } ;
25
25
use crate :: verification:: { EkuError , Verifier } ;
26
26
use rustls:: { client:: ServerCertVerifier , CertificateError , Error as TlsError } ;
27
27
use std:: convert:: TryFrom ;
@@ -95,7 +95,7 @@ pub(super) fn verification_without_mock_root() {
95
95
& server_name,
96
96
& mut std:: iter:: empty ( ) ,
97
97
& [ ] ,
98
- std :: time :: SystemTime :: now ( ) ,
98
+ verification_time ( ) ,
99
99
) ;
100
100
101
101
assert_eq ! (
@@ -120,41 +120,47 @@ mock_root_test_cases! {
120
120
reference_id: EXAMPLE_COM ,
121
121
chain: & [ ROOT1_INT1_EXAMPLE_COM_GOOD , ROOT1_INT1 ] ,
122
122
stapled_ocsp: None ,
123
+ verification_time: verification_time( ) ,
123
124
expected_result: Ok ( ( ) ) ,
124
125
other_error: no_error!( ) ,
125
126
} ,
126
127
valid_no_stapling_ipv4 [ any( windows, target_os = "android" , target_os = "macos" , target_os = "linux" ) ] => TestCase {
127
128
reference_id: LOCALHOST_IPV4 ,
128
129
chain: & [ ROOT1_INT1_LOCALHOST_IPV4_GOOD , ROOT1_INT1 ] ,
129
130
stapled_ocsp: None ,
131
+ verification_time: verification_time( ) ,
130
132
expected_result: Ok ( ( ) ) ,
131
133
other_error: no_error!( ) ,
132
134
} ,
133
135
valid_no_stapling_ipv6 [ any( windows, target_os = "android" , target_os = "macos" , target_os = "linux" ) ] => TestCase {
134
136
reference_id: LOCALHOST_IPV6 ,
135
137
chain: & [ ROOT1_INT1_LOCALHOST_IPV6_GOOD , ROOT1_INT1 ] ,
136
138
stapled_ocsp: None ,
139
+ verification_time: verification_time( ) ,
137
140
expected_result: Ok ( ( ) ) ,
138
141
other_error: no_error!( ) ,
139
142
} ,
140
143
valid_stapled_good_dns [ any( windows, target_os = "android" , target_os = "android" , target_os = "macos" , target_os = "linux" ) ] => TestCase {
141
144
reference_id: EXAMPLE_COM ,
142
145
chain: & [ ROOT1_INT1_EXAMPLE_COM_GOOD , ROOT1_INT1 ] ,
143
146
stapled_ocsp: Some ( include_bytes!( "root1-int1-ee_example.com-good.ocsp" ) ) ,
147
+ verification_time: verification_time( ) ,
144
148
expected_result: Ok ( ( ) ) ,
145
149
other_error: no_error!( ) ,
146
150
} ,
147
151
valid_stapled_good_ipv4 [ any( windows, target_os = "android" , target_os = "macos" , target_os = "linux" ) ] => TestCase {
148
152
reference_id: LOCALHOST_IPV4 ,
149
153
chain: & [ ROOT1_INT1_LOCALHOST_IPV4_GOOD , ROOT1_INT1 ] ,
150
154
stapled_ocsp: Some ( include_bytes!( "root1-int1-ee_127.0.0.1-good.ocsp" ) ) ,
155
+ verification_time: verification_time( ) ,
151
156
expected_result: Ok ( ( ) ) ,
152
157
other_error: no_error!( ) ,
153
158
} ,
154
159
valid_stapled_good_ipv6 [ any( windows, target_os = "android" , target_os = "macos" , target_os = "linux" ) ] => TestCase {
155
160
reference_id: LOCALHOST_IPV6 ,
156
161
chain: & [ ROOT1_INT1_LOCALHOST_IPV6_GOOD , ROOT1_INT1 ] ,
157
162
stapled_ocsp: Some ( include_bytes!( "root1-int1-ee_1-good.ocsp" ) ) ,
163
+ verification_time: verification_time( ) ,
158
164
expected_result: Ok ( ( ) ) ,
159
165
other_error: no_error!( ) ,
160
166
} ,
@@ -166,20 +172,23 @@ mock_root_test_cases! {
166
172
reference_id: EXAMPLE_COM ,
167
173
chain: & [ include_bytes!( "root1-int1-ee_example.com-revoked.crt" ) , ROOT1_INT1 ] ,
168
174
stapled_ocsp: Some ( include_bytes!( "root1-int1-ee_example.com-revoked.ocsp" ) ) ,
175
+ verification_time: verification_time( ) ,
169
176
expected_result: Err ( TlsError :: InvalidCertificate ( CertificateError :: Revoked ) ) ,
170
177
other_error: no_error!( ) ,
171
178
} ,
172
179
stapled_revoked_ipv4 [ any( windows, target_os = "android" , target_os = "macos" ) ] => TestCase {
173
180
reference_id: LOCALHOST_IPV4 ,
174
181
chain: & [ include_bytes!( "root1-int1-ee_127.0.0.1-revoked.crt" ) , ROOT1_INT1 ] ,
175
182
stapled_ocsp: Some ( include_bytes!( "root1-int1-ee_127.0.0.1-revoked.ocsp" ) ) ,
183
+ verification_time: verification_time( ) ,
176
184
expected_result: Err ( TlsError :: InvalidCertificate ( CertificateError :: Revoked ) ) ,
177
185
other_error: no_error!( ) ,
178
186
} ,
179
187
stapled_revoked_ipv6 [ any( windows, target_os = "android" , target_os = "macos" ) ] => TestCase {
180
188
reference_id: LOCALHOST_IPV6 ,
181
189
chain: & [ include_bytes!( "root1-int1-ee_1-revoked.crt" ) , ROOT1_INT1 ] ,
182
190
stapled_ocsp: Some ( include_bytes!( "root1-int1-ee_1-revoked.ocsp" ) ) ,
191
+ verification_time: verification_time( ) ,
183
192
expected_result: Err ( TlsError :: InvalidCertificate ( CertificateError :: Revoked ) ) ,
184
193
other_error: no_error!( ) ,
185
194
} ,
@@ -192,20 +201,23 @@ mock_root_test_cases! {
192
201
reference_id: EXAMPLE_COM ,
193
202
chain: & [ ROOT1_INT1_EXAMPLE_COM_GOOD ] ,
194
203
stapled_ocsp: None ,
204
+ verification_time: verification_time( ) ,
195
205
expected_result: Err ( TlsError :: InvalidCertificate ( CertificateError :: UnknownIssuer ) ) ,
196
206
other_error: no_error!( ) ,
197
207
} ,
198
208
ee_only_ipv4 [ any( windows, target_os = "android" , target_os = "macos" , target_os = "linux" ) ] => TestCase {
199
209
reference_id: LOCALHOST_IPV4 ,
200
210
chain: & [ ROOT1_INT1_LOCALHOST_IPV4_GOOD ] ,
201
211
stapled_ocsp: None ,
212
+ verification_time: verification_time( ) ,
202
213
expected_result: Err ( TlsError :: InvalidCertificate ( CertificateError :: UnknownIssuer ) ) ,
203
214
other_error: no_error!( ) ,
204
215
} ,
205
216
ee_only_ipv6 [ any( windows, target_os = "android" , target_os = "macos" , target_os = "linux" ) ] => TestCase {
206
217
reference_id: LOCALHOST_IPV6 ,
207
218
chain: & [ ROOT1_INT1_LOCALHOST_IPV6_GOOD ] ,
208
219
stapled_ocsp: None ,
220
+ verification_time: verification_time( ) ,
209
221
expected_result: Err ( TlsError :: InvalidCertificate ( CertificateError :: UnknownIssuer ) ) ,
210
222
other_error: no_error!( ) ,
211
223
} ,
@@ -214,27 +226,31 @@ mock_root_test_cases! {
214
226
reference_id: "example.org" ,
215
227
chain: & [ ROOT1_INT1_EXAMPLE_COM_GOOD , ROOT1_INT1 ] ,
216
228
stapled_ocsp: None ,
229
+ verification_time: verification_time( ) ,
217
230
expected_result: Err ( TlsError :: InvalidCertificate ( CertificateError :: NotValidForName ) ) ,
218
231
other_error: no_error!( ) ,
219
232
} ,
220
233
domain_mismatch_ipv4 [ any( windows, target_os = "android" , target_os = "macos" , target_os = "linux" ) ] => TestCase {
221
234
reference_id: "198.168.0.1" ,
222
235
chain: & [ ROOT1_INT1_LOCALHOST_IPV4_GOOD , ROOT1_INT1 ] ,
223
236
stapled_ocsp: None ,
237
+ verification_time: verification_time( ) ,
224
238
expected_result: Err ( TlsError :: InvalidCertificate ( CertificateError :: NotValidForName ) ) ,
225
239
other_error: no_error!( ) ,
226
240
} ,
227
241
domain_mismatch_ipv6 [ any( windows, target_os = "android" , target_os = "macos" , target_os = "linux" ) ] => TestCase {
228
242
reference_id: "::ffff:c6a8:1" ,
229
243
chain: & [ ROOT1_INT1_LOCALHOST_IPV6_GOOD , ROOT1_INT1 ] ,
230
244
stapled_ocsp: None ,
245
+ verification_time: verification_time( ) ,
231
246
expected_result: Err ( TlsError :: InvalidCertificate ( CertificateError :: NotValidForName ) ) ,
232
247
other_error: no_error!( ) ,
233
248
} ,
234
249
wrong_eku_dns [ any( windows, target_os = "android" , target_os = "macos" , target_os = "linux" ) ] => TestCase {
235
250
reference_id: EXAMPLE_COM ,
236
251
chain: & [ include_bytes!( "root1-int1-ee_example.com-wrong_eku.crt" ) , ROOT1_INT1 ] ,
237
252
stapled_ocsp: None ,
253
+ verification_time: verification_time( ) ,
238
254
expected_result: Err ( TlsError :: InvalidCertificate (
239
255
CertificateError :: Other ( Arc :: from( EkuError ) ) ) ) ,
240
256
other_error: Some ( EkuError ) ,
@@ -243,6 +259,7 @@ mock_root_test_cases! {
243
259
reference_id: LOCALHOST_IPV4 ,
244
260
chain: & [ include_bytes!( "root1-int1-ee_127.0.0.1-wrong_eku.crt" ) , ROOT1_INT1 ] ,
245
261
stapled_ocsp: None ,
262
+ verification_time: verification_time( ) ,
246
263
expected_result: Err ( TlsError :: InvalidCertificate (
247
264
CertificateError :: Other ( Arc :: from( EkuError ) ) ) ) ,
248
265
other_error: Some ( EkuError ) ,
@@ -251,6 +268,7 @@ mock_root_test_cases! {
251
268
reference_id: LOCALHOST_IPV6 ,
252
269
chain: & [ include_bytes!( "root1-int1-ee_1-wrong_eku.crt" ) , ROOT1_INT1 ] ,
253
270
stapled_ocsp: None ,
271
+ verification_time: verification_time( ) ,
254
272
expected_result: Err ( TlsError :: InvalidCertificate (
255
273
CertificateError :: Other ( Arc :: from( EkuError ) ) ) ) ,
256
274
other_error: Some ( EkuError ) ,
@@ -289,7 +307,7 @@ fn test_with_mock_root<E: std::error::Error + PartialEq + 'static>(test_case: &T
289
307
& server_name,
290
308
& mut std:: iter:: empty ( ) ,
291
309
test_case. stapled_ocsp . unwrap_or ( & [ ] ) ,
292
- std :: time :: SystemTime :: now ( ) ,
310
+ test_case . verification_time ,
293
311
) ;
294
312
295
313
assert_cert_error_eq (
0 commit comments