Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cargo: update to rustls 0.22, associated updates #42

Merged
merged 1 commit into from
Jan 12, 2024
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
163 changes: 58 additions & 105 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions rustls-platform-verifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,31 @@ cert-logging = ["base64"]
docsrs = ["jni", "once_cell"]

[dependencies]
rustls = { version = "0.21", features = ["dangerous_configuration", "tls12", "logging"] }
rustls = { version = "0.22.1", features = ["tls12", "logging"] }
log = { version = "0.4" }
base64 = { version = "0.21", optional = true } # Only used when the `cert-logging` feature is enabled.
jni = { version = "0.19", default-features = false, optional = true } # Only used during doc generation
once_cell = { version = "1.9", optional = true } # Only used during doc generation.

[target.'cfg(all(unix, not(target_os = "android"), not(target_os = "macos"), not(target_os = "ios")))'.dependencies]
rustls-native-certs = "0.6"
rustls-native-certs = "0.7"
once_cell = "1.9"
webpki = { package = "rustls-webpki", version = "0.101", features = ["alloc", "std"] }
webpki = { package = "rustls-webpki", version = "0.102", features = ["ring", "alloc", "std"] }

[target.'cfg(target_os = "android")'.dependencies]
rustls-platform-verifier-android = { path = "../android-release-support", version = "0.1.0" }
jni = { version = "0.19", default-features = false }
webpki = { package = "rustls-webpki", version = "0.101", features = ["alloc", "std"] }
webpki = { package = "rustls-webpki", version = "0.102", features = ["ring", "alloc", "std"] }
once_cell = "1.9"
android_logger = { version = "0.13", optional = true } # Only used during testing.

[target.'cfg(target_arch = "wasm32")'.dependencies]
once_cell = "1.9"
webpki-roots = "0.25"
webpki-roots = "0.26"

# BSD targets require webpki-roots for the real-world verification tests.
[target.'cfg(target_os = "freebsd")'.dev-dependencies]
webpki-roots = "0.25"
webpki-roots = "0.26"

[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
core-foundation = "0.9"
Expand Down
8 changes: 4 additions & 4 deletions rustls-platform-verifier/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ pub use tests::ffi::*;
///
/// If you require more control over the rustls `ClientConfig`, you can
/// instantiate a [Verifier] with [Verifier::default] and then use it
/// with [rustls::ConfigBuilder::with_custom_certificate_verifier].
/// with [rustls::ConfigBuilder::dangerous::with_custom_certificate_verifier].
///
/// Refer to the crate level documentation to see what platforms
/// are currently supported.
pub fn tls_config() -> ClientConfig {
rustls::ClientConfig::builder()
.with_safe_defaults()
ClientConfig::builder()
.dangerous()
.with_custom_certificate_verifier(Arc::new(Verifier::new()))
.with_no_client_auth()
}
Expand All @@ -69,6 +69,6 @@ pub fn tls_config() -> ClientConfig {
///
/// This is not intended for production use, you should use [tls_config] instead.
#[cfg(feature = "dbg")]
pub fn verifier_for_dbg(root: &[u8]) -> Arc<dyn rustls::client::ServerCertVerifier> {
pub fn verifier_for_dbg(root: &[u8]) -> Arc<dyn rustls::client::danger::ServerCertVerifier> {
Arc::new(Verifier::new_with_fake_root(root))
}
11 changes: 6 additions & 5 deletions rustls-platform-verifier/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
pub mod ffi;

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

mod verification_real_world;

mod verification_mock;

use rustls::{CertificateError, Error as TlsError, Error::InvalidCertificate};
use rustls::{pki_types, CertificateError, Error as TlsError, Error::InvalidCertificate};

struct TestCase<'a, E: StdError> {
/// The name of the server we're connecting to.
Expand All @@ -21,7 +21,7 @@ struct TestCase<'a, E: StdError> {
pub stapled_ocsp: Option<&'a [u8]>,

/// The time to use as the current time for verification.
pub verification_time: SystemTime,
pub verification_time: pki_types::UnixTime,

pub expected_result: Result<(), TlsError>,

Expand All @@ -43,6 +43,7 @@ pub fn assert_cert_error_eq<E: StdError + PartialEq + 'static>(
if let Err(InvalidCertificate(CertificateError::Other(err))) = &expected {
let expected_err = expected_err.expect("error not provided for `Other` case handling");
let err: &E = err
.0
.downcast_ref()
.expect("incorrect `Other` inner error kind");
assert_eq!(err, expected_err);
Expand All @@ -56,7 +57,7 @@ pub fn assert_cert_error_eq<E: StdError + PartialEq + 'static>(
/// 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() -> SystemTime {
pub(crate) fn verification_time() -> pki_types::UnixTime {
// Wednesday, January 3, 2024 6:03:08 PM UTC
SystemTime::UNIX_EPOCH + Duration::from_secs(1_704_304_988)
pki_types::UnixTime::since_unix_epoch(Duration::from_secs(1_704_304_988))
}
Loading
Loading