Skip to content

Commit 40f2bda

Browse files
committed
Move to direct AWS certificate chain for secondary real-world CA test
1 parent a365860 commit 40f2bda

File tree

10 files changed

+60
-34
lines changed

10 files changed

+60
-34
lines changed

rustls-platform-verifier/examples/update-certs.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
4444
Ok(())
4545
}
4646

47-
const HOSTS: &[&str] = &["letsencrypt.org"];
47+
// We use two different CAs for better coverage and...
48+
const HOSTS: &[&str] = &[
49+
// This host is using EC-based certificates for coverage.
50+
"letsencrypt.org",
51+
// This host is using RSA-based certificates for coverage.
52+
"aws.amazon.com",
53+
];

rustls-platform-verifier/src/tests/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ pub fn assert_cert_error_eq<E: StdError + PartialEq + 'static>(
6262
/// we know the test certificates are valid. This must be updated if the mock certificates
6363
/// are regenerated.
6464
pub(crate) fn verification_time() -> pki_types::UnixTime {
65-
// Fri, 30 May 2025 21:27:00 UTC
66-
pki_types::UnixTime::since_unix_epoch(Duration::from_secs(1_748_633_220))
65+
// Wed, 13 August 2025 18:30:53 UTC
66+
pki_types::UnixTime::since_unix_epoch(Duration::from_secs(1_755_109_853))
6767
}
6868

6969
fn test_provider() -> Arc<CryptoProvider> {
Binary file not shown.

rustls-platform-verifier/src/tests/verification_real_world/mod.rs

Lines changed: 51 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -46,29 +46,49 @@ use crate::tests::{assert_cert_error_eq, test_provider, verification_time};
4646
use crate::Verifier;
4747

4848
// 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.
5250
//
5351
// Use this to template view the certificate using OpenSSL:
5452
// ```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
5654
// ```
5755
//
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"),
6361
// XXX: This certificate is included for testing in environments that might need
6462
// 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"),
6664
];
6765

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+
}
6986

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.
7190
const VALID_UNRELATED_DOMAIN: &str = "my.1password.com";
91+
const VALID_UNRELATED_SUBDOMAIN: &str = "www.amazon.com";
7292

7393
const LETSENCRYPT_ORG: &str = "letsencrypt.org";
7494

@@ -167,43 +187,43 @@ fn real_world_test<E: std::error::Error>(test_case: &TestCase<E>) {
167187
// Prefer to staple the OCSP response for the end-entity certificate for
168188
// performance and repeatability.
169189
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,
174194
stapled_ocsp: None,
175195
verification_time: verification_time(),
176196
expected_result: Ok(()),
177197
other_error: no_error!(),
178198
},
179199
// 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,
183203
stapled_ocsp: None,
184204
verification_time: verification_time(),
185205
expected_result: Ok(()),
186206
other_error: no_error!(),
187207
},
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,
192212
stapled_ocsp: None,
193213
verification_time: verification_time(),
194214
expected_result: Ok(()),
195215
other_error: no_error!(),
196216
},
197217
// The certificate isn't valid for an unrelated subdomain.
198218
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,
201221
stapled_ocsp: None,
202222
verification_time: verification_time(),
203223
#[cfg(not(any(target_vendor = "apple", windows)))]
204224
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(),
207227
})),
208228
#[cfg(any(target_vendor = "apple", windows))]
209229
expected_result: Err(TlsError::InvalidCertificate(CertificateError::NotValidForName)),
@@ -212,14 +232,14 @@ real_world_test_cases! {
212232
// The certificate chain for the unrelated domain is not valid for
213233
// my.1password.com.
214234
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,
217237
stapled_ocsp: None,
218238
verification_time: verification_time(),
219239
#[cfg(not(any(target_vendor = "apple", windows)))]
220240
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(),
223243
})),
224244
#[cfg(any(target_vendor = "apple", windows))]
225245
expected_result: Err(TlsError::InvalidCertificate(CertificateError::NotValidForName)),

0 commit comments

Comments
 (0)