Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions rustls-platform-verifier/src/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#[cfg(feature = "ffi-testing")]
pub mod ffi;

use std::time::Duration;
use std::{error::Error as StdError, sync::Arc};

mod verification_real_world;
Expand Down Expand Up @@ -56,16 +55,6 @@ pub fn assert_cert_error_eq<E: StdError + PartialEq + 'static>(
}
}

/// Return a fixed [`pki_types::UnixTime`] for certificate validation purposes.
///
/// We fix the "now" value used for certificate validation to a fixed point in time at which
/// we know the test certificates are valid. This must be updated if the mock certificates
/// are regenerated.
pub(crate) fn verification_time() -> pki_types::UnixTime {
// Wed, 12 Aug 2026 10:23 UTC
pki_types::UnixTime::since_unix_epoch(Duration::from_secs(1_786_530_173))
}

fn test_provider() -> Arc<CryptoProvider> {
Arc::new(rustls::crypto::ring::default_provider())
}
13 changes: 12 additions & 1 deletion rustls-platform-verifier/src/tests/verification_mock/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
not(target_os = "visionos")
))]

use core::time::Duration;
use std::convert::TryFrom;
use std::net::IpAddr;
#[cfg(not(any(target_vendor = "apple", windows)))]
Expand All @@ -34,7 +35,7 @@ use rustls::pki_types::{DnsName, ServerName};
use rustls::{CertificateError, Error as TlsError, OtherError};

use super::TestCase;
use crate::tests::{assert_cert_error_eq, test_provider, verification_time};
use crate::tests::{assert_cert_error_eq, test_provider};
use crate::verification::{EkuError, Verifier};

macro_rules! mock_root_test_cases {
Expand Down Expand Up @@ -399,3 +400,13 @@ enum Roots {
#[cfg(not(target_os = "android"))]
ExtraAndPlatform,
}

/// Return a fixed [`pki_types::UnixTime`] for certificate validation purposes.
///
/// We fix the "now" value used for certificate validation to a fixed point in time at which
/// we know the test certificates are valid. This must be updated if the mock certificates
/// are regenerated.
pub(crate) fn verification_time() -> pki_types::UnixTime {
// Wed, Sep 9 2026 11:52 UTC
pki_types::UnixTime::since_unix_epoch(Duration::from_secs(1_788_954_730))
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified rustls-platform-verifier/src/tests/verification_mock/root1.crt
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,16 @@
//! Thus we don't expect these tests to be flaky w.r.t. that, except for
//! potentially poor performance.

use core::time::Duration;

use rustls::client::danger::ServerCertVerifier;
use rustls::pki_types;
#[cfg(not(any(target_vendor = "apple", windows)))]
use rustls::pki_types::{DnsName, ServerName};
use rustls::{CertificateError, Error as TlsError};

use super::TestCase;
use crate::tests::{assert_cert_error_eq, test_provider, verification_time};
use crate::tests::{assert_cert_error_eq, test_provider};
use crate::Verifier;

// This is the certificate chain presented by one server for
Expand Down Expand Up @@ -276,3 +278,13 @@ real_world_test_cases! {
// valid: !cfg!(windows),
// },
}

/// Return a fixed [`pki_types::UnixTime`] for certificate validation purposes.
///
/// We fix the "now" value used for certificate validation to a fixed point in time at which
/// we know the test certificates are valid. This must be updated if the mock certificates
/// are regenerated.
pub(crate) fn verification_time() -> pki_types::UnixTime {
// Wed, 12 Aug 2026 10:23 UTC
pki_types::UnixTime::since_unix_epoch(Duration::from_secs(1_786_530_173))
}
Loading