@@ -46,29 +46,49 @@ use crate::tests::{assert_cert_error_eq, test_provider, verification_time};
46
46
use crate :: Verifier ;
47
47
48
48
// This is the certificate chain presented by one server for
49
- // my.1password.com when this test was updated 2023-08-01. It is
50
- // valid for *.1password.com and 1password.com from
51
- // "Jun 24 00:00:00 2023 GMT" through "Jul 22 23:59:59 2024 GMT".
49
+ // `aws.amazon.com` when this test was updated 2025-08-13.
52
50
//
53
51
// Use this to template view the certificate using OpenSSL:
54
52
// ```sh
55
- // openssl x509 -inform der -text -in 1password_com_valid_1 .crt | less
53
+ // openssl x509 -inform der -text -in aws_amazon_com_valid_1 .crt | less
56
54
// ```
57
55
//
58
- // You can update the cert file with `update_valid_ee_certs .rs`
59
- const VALID_1PASSWORD_COM_CHAIN : & [ & [ u8 ] ] = & [
60
- include_bytes ! ( "1password_com_valid_1 .crt" ) ,
61
- include_bytes ! ( "1password_com_valid_2 .crt" ) ,
62
- include_bytes ! ( "1password_com_valid_3 .crt" ) ,
56
+ // You can update these cert files with `examples/update-certs .rs`
57
+ const VALID_AWS_AMAZON_COM_CHAIN : & [ & [ u8 ] ] = & [
58
+ include_bytes ! ( "aws_amazon_com_valid_1 .crt" ) ,
59
+ include_bytes ! ( "aws_amazon_com_valid_2 .crt" ) ,
60
+ include_bytes ! ( "aws_amazon_com_valid_3 .crt" ) ,
63
61
// XXX: This certificate is included for testing in environments that might need
64
62
// a cross-signed root certificate instead of the just the server-provided one.
65
- include_bytes ! ( "1password_com_valid_4 .crt" ) ,
63
+ include_bytes ! ( "aws_amazon_com_valid_4 .crt" ) ,
66
64
] ;
67
65
68
- const MY_1PASSWORD_COM : & str = "my.1password.com" ;
66
+ /// Returns a list of names valid for [VALID_AWS_AMAZON_COM_CHAIN], in a format
67
+ /// expected by `CertificateError::NotValidForContext`.
68
+ #[ cfg( not( any( target_vendor = "apple" , windows) ) ) ]
69
+ fn valid_aws_chain_names ( ) -> Vec < String > {
70
+ const VALID_AWS_NAMES : & [ & str ] = & [
71
+ "aws.amazon.com" ,
72
+ "www.aws.amazon.com" ,
73
+ "aws-us-east-1.amazon.com" ,
74
+ "aws-us-west-2.amazon.com" ,
75
+ "amazonaws-china.com" ,
76
+ "www.amazonaws-china.com" ,
77
+ "1.aws-lbr.amazonaws.com" ,
78
+ ] ;
79
+
80
+ VALID_AWS_NAMES
81
+ . iter ( )
82
+ . copied ( )
83
+ . map ( |name| format ! ( "DnsName(\" {name}\" )" ) )
84
+ . collect ( )
85
+ }
69
86
70
- // A domain name for which `VALID_AWS_AMAZON_COM_CHAIN` isn't valid.
87
+ const AWS_AMAZON_COM : & str = "aws.amazon.com" ;
88
+
89
+ // Domain names for which `VALID_AWS_AMAZON_COM_CHAIN` isn't valid.
71
90
const VALID_UNRELATED_DOMAIN : & str = "my.1password.com" ;
91
+ const VALID_UNRELATED_SUBDOMAIN : & str = "www.amazon.com" ;
72
92
73
93
const LETSENCRYPT_ORG : & str = "letsencrypt.org" ;
74
94
@@ -167,43 +187,43 @@ fn real_world_test<E: std::error::Error>(test_case: &TestCase<E>) {
167
187
// Prefer to staple the OCSP response for the end-entity certificate for
168
188
// performance and repeatability.
169
189
real_world_test_cases ! {
170
- // The certificate is valid for *.1password .com.
171
- my_1password_com_valid => TestCase {
172
- reference_id: MY_1PASSWORD_COM ,
173
- chain: VALID_1PASSWORD_COM_CHAIN ,
190
+ // The certificate is valid for *.aws.amazon .com.
191
+ aws_amazon_com_valid => TestCase {
192
+ reference_id: AWS_AMAZON_COM ,
193
+ chain: VALID_AWS_AMAZON_COM_CHAIN ,
174
194
stapled_ocsp: None ,
175
195
verification_time: verification_time( ) ,
176
196
expected_result: Ok ( ( ) ) ,
177
197
other_error: no_error!( ) ,
178
198
} ,
179
199
// Same as above but without stapled OCSP.
180
- my_1password_com_valid_no_stapled => TestCase {
181
- reference_id: MY_1PASSWORD_COM ,
182
- chain: VALID_1PASSWORD_COM_CHAIN ,
200
+ aws_amazon_com_valid_no_stapled => TestCase {
201
+ reference_id: AWS_AMAZON_COM ,
202
+ chain: VALID_AWS_AMAZON_COM_CHAIN ,
183
203
stapled_ocsp: None ,
184
204
verification_time: verification_time( ) ,
185
205
expected_result: Ok ( ( ) ) ,
186
206
other_error: no_error!( ) ,
187
207
} ,
188
- // Valid also for 1password. com (no subdomain).
189
- _1password_com_valid => TestCase {
190
- reference_id: "1password .com" ,
191
- chain: VALID_1PASSWORD_COM_CHAIN ,
208
+ // Valid also for www.amazon.amazon. com (extra subdomain).
209
+ _aws_amazon_com_valid => TestCase {
210
+ reference_id: "www.aws.amazon .com" ,
211
+ chain: VALID_AWS_AMAZON_COM_CHAIN ,
192
212
stapled_ocsp: None ,
193
213
verification_time: verification_time( ) ,
194
214
expected_result: Ok ( ( ) ) ,
195
215
other_error: no_error!( ) ,
196
216
} ,
197
217
// The certificate isn't valid for an unrelated subdomain.
198
218
unrelated_domain_invalid => TestCase {
199
- reference_id: VALID_UNRELATED_DOMAIN ,
200
- chain: VALID_1PASSWORD_COM_CHAIN ,
219
+ reference_id: VALID_UNRELATED_SUBDOMAIN ,
220
+ chain: VALID_AWS_AMAZON_COM_CHAIN ,
201
221
stapled_ocsp: None ,
202
222
verification_time: verification_time( ) ,
203
223
#[ cfg( not( any( target_vendor = "apple" , windows) ) ) ]
204
224
expected_result: Err ( TlsError :: InvalidCertificate ( CertificateError :: NotValidForNameContext {
205
- expected: ServerName :: DnsName ( DnsName :: try_from( "agilebits.com" ) . unwrap( ) ) ,
206
- presented: vec! [ "DnsName( \" *.1password.com \" )" . to_owned ( ) , "DnsName( \" 1password.com \" )" . to_owned ( ) ] ,
225
+ expected: ServerName :: DnsName ( DnsName :: try_from( VALID_UNRELATED_SUBDOMAIN ) . unwrap( ) ) ,
226
+ presented: valid_aws_chain_names ( ) ,
207
227
} ) ) ,
208
228
#[ cfg( any( target_vendor = "apple" , windows) ) ]
209
229
expected_result: Err ( TlsError :: InvalidCertificate ( CertificateError :: NotValidForName ) ) ,
@@ -212,14 +232,14 @@ real_world_test_cases! {
212
232
// The certificate chain for the unrelated domain is not valid for
213
233
// my.1password.com.
214
234
unrelated_chain_not_valid_for_my_1password_com => TestCase {
215
- reference_id: MY_1PASSWORD_COM ,
216
- chain: VALID_UNRELATED_CHAIN ,
235
+ reference_id: VALID_UNRELATED_DOMAIN ,
236
+ chain: VALID_AWS_AMAZON_COM_CHAIN ,
217
237
stapled_ocsp: None ,
218
238
verification_time: verification_time( ) ,
219
239
#[ cfg( not( any( target_vendor = "apple" , windows) ) ) ]
220
240
expected_result: Err ( TlsError :: InvalidCertificate ( CertificateError :: NotValidForNameContext {
221
- expected: ServerName :: DnsName ( DnsName :: try_from( "my.1password.com" ) . unwrap( ) ) ,
222
- presented: vec! [ "DnsName( \" agilebits.com \" )" . to_owned ( ) , "DnsName( \" www.agilebits.com \" )" . to_owned ( ) ] ,
241
+ expected: ServerName :: DnsName ( DnsName :: try_from( VALID_UNRELATED_DOMAIN ) . unwrap( ) ) ,
242
+ presented: valid_aws_chain_names ( ) ,
223
243
} ) ) ,
224
244
#[ cfg( any( target_vendor = "apple" , windows) ) ]
225
245
expected_result: Err ( TlsError :: InvalidCertificate ( CertificateError :: NotValidForName ) ) ,
0 commit comments