Skip to content

Commit 726d0a2

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

File tree

10 files changed

+50
-34
lines changed

10 files changed

+50
-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: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -46,29 +46,39 @@ 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+
#[cfg(not(any(target_vendor = "apple", windows)))]
67+
const VALID_AWS_NAMES: &[&str] = &[
68+
"aws.amazon.com",
69+
"www.aws.amazon.com",
70+
"aws-us-east-1.amazon.com",
71+
"aws-us-west-2.amazon.com",
72+
"amazonaws-china.com",
73+
"www.amazonaws-china.com",
74+
"1.aws-lbr.amazonaws.com",
75+
];
76+
77+
const AWS_AMAZON_COM: &str = "aws.amazon.com";
6978

70-
// A domain name for which `VALID_AWS_AMAZON_COM_CHAIN` isn't valid.
79+
// Domain names for which `VALID_AWS_AMAZON_COM_CHAIN` isn't valid.
7180
const VALID_UNRELATED_DOMAIN: &str = "my.1password.com";
81+
const VALID_UNRELATED_SUBDOMAIN: &str = "www.amazon.com";
7282

7383
const LETSENCRYPT_ORG: &str = "letsencrypt.org";
7484

@@ -167,43 +177,43 @@ fn real_world_test<E: std::error::Error>(test_case: &TestCase<E>) {
167177
// Prefer to staple the OCSP response for the end-entity certificate for
168178
// performance and repeatability.
169179
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,
180+
// The certificate is valid for *.aws.amazon.com.
181+
aws_amazon_com_valid => TestCase {
182+
reference_id: AWS_AMAZON_COM,
183+
chain: VALID_AWS_AMAZON_COM_CHAIN,
174184
stapled_ocsp: None,
175185
verification_time: verification_time(),
176186
expected_result: Ok(()),
177187
other_error: no_error!(),
178188
},
179189
// 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,
190+
aws_amazon_com_valid_no_stapled => TestCase {
191+
reference_id: AWS_AMAZON_COM,
192+
chain: VALID_AWS_AMAZON_COM_CHAIN,
183193
stapled_ocsp: None,
184194
verification_time: verification_time(),
185195
expected_result: Ok(()),
186196
other_error: no_error!(),
187197
},
188-
// Valid also for 1password.com (no subdomain).
189-
_1password_com_valid => TestCase {
190-
reference_id: "1password.com",
191-
chain: VALID_1PASSWORD_COM_CHAIN,
198+
// Valid also for www.amazon.amazon.com (extra subdomain).
199+
_aws_amazon_com_valid => TestCase {
200+
reference_id: "www.aws.amazon.com",
201+
chain: VALID_AWS_AMAZON_COM_CHAIN,
192202
stapled_ocsp: None,
193203
verification_time: verification_time(),
194204
expected_result: Ok(()),
195205
other_error: no_error!(),
196206
},
197207
// The certificate isn't valid for an unrelated subdomain.
198208
unrelated_domain_invalid => TestCase {
199-
reference_id: VALID_UNRELATED_DOMAIN,
200-
chain: VALID_1PASSWORD_COM_CHAIN,
209+
reference_id: VALID_UNRELATED_SUBDOMAIN,
210+
chain: VALID_AWS_AMAZON_COM_CHAIN,
201211
stapled_ocsp: None,
202212
verification_time: verification_time(),
203213
#[cfg(not(any(target_vendor = "apple", windows)))]
204214
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()],
215+
expected: ServerName::DnsName(DnsName::try_from(VALID_UNRELATED_SUBDOMAIN).unwrap()),
216+
presented: Vec::from(VALID_AWS_NAMES),
207217
})),
208218
#[cfg(any(target_vendor = "apple", windows))]
209219
expected_result: Err(TlsError::InvalidCertificate(CertificateError::NotValidForName)),
@@ -212,14 +222,14 @@ real_world_test_cases! {
212222
// The certificate chain for the unrelated domain is not valid for
213223
// my.1password.com.
214224
unrelated_chain_not_valid_for_my_1password_com => TestCase {
215-
reference_id: MY_1PASSWORD_COM,
216-
chain: VALID_UNRELATED_CHAIN,
225+
reference_id: VALID_UNRELATED_DOMAIN,
226+
chain: VALID_AWS_AMAZON_COM_CHAIN,
217227
stapled_ocsp: None,
218228
verification_time: verification_time(),
219229
#[cfg(not(any(target_vendor = "apple", windows)))]
220230
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()],
231+
expected: ServerName::DnsName(DnsName::try_from(VALID_UNRELATED_DOMAIN).unwrap()),
232+
presented: Vec::from(VALID_AWS_NAMES),
223233
})),
224234
#[cfg(any(target_vendor = "apple", windows))]
225235
expected_result: Err(TlsError::InvalidCertificate(CertificateError::NotValidForName)),

0 commit comments

Comments
 (0)