Skip to content

Commit 9957dcc

Browse files
committed
Cargo: update to rustls 0.22, associated updates
For the time being, this branch continues to unconditionally use *ring* as the crypto provider. Follow-up work to expose this as a choice (e.g allowing aws-lc-rs as a provider) may be interesting. Deps: * updated rustls 0.21 -> 0.22.1 Linux deps: * rustls-native-certs 0.6 -> 0.7 * webpki 0.101 -> 0.102 Android deps: * webpki 0.101 -> 0.102 WASM32 deps: * webpki-roots 0.25 -> 0.26 Summary of breaking change updates: * We use rustls 0.22.1 in specific to benefit from the `pki_types` re-export, removing the need to add that as our own dep with matching version. * `ServerName`, `Certificate`, and `OwnedTrustAnchor` types are now sourced from `pki_types`, with an associated generic lifetime. The `OwnedTrustAnchor` type is now just `TrustAnchor`. * The 'dangerous' rustls crate feature was removed, and associated items moved into new locations with the import path emphasizing danger. * "Other error" types changed to use a specific `rustls::OtherError` inner variant. * `SystemTime` for verifiers replaced with `pki_types::UnixTime`. * Default fns on `ServerCertVerifier` trait were removed, must be reconstituted with `rustls::verify_tls12_signature`, `rustls::verify_tls13_signature` and `WebPkiSupportedAlgorithms.supported_schemes` using a `CryptoProvider`. * `ServerName` now supports a `to_str` operation, avoiding the need to `match` and handle unsupported name types. * `WebPkiVerifier` was renamed to `WebPkiServerVerifier`, handled as an `Arc` and constructed with a builder.
1 parent 0479b6e commit 9957dcc

File tree

11 files changed

+343
-302
lines changed

11 files changed

+343
-302
lines changed

Cargo.lock

Lines changed: 58 additions & 105 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,26 @@ cert-logging = ["base64"]
3737
docsrs = ["jni", "once_cell"]
3838

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

4646
[target.'cfg(target_os = "linux")'.dependencies]
47-
rustls-native-certs = "0.6"
47+
rustls-native-certs = "0.7"
4848
once_cell = "1.9"
49-
webpki = { package = "rustls-webpki", version = "0.101", features = ["alloc", "std"] }
49+
webpki = { package = "rustls-webpki", version = "0.102", features = ["ring", "alloc", "std"] }
5050

5151
[target.'cfg(target_os = "android")'.dependencies]
5252
jni = { version = "0.19", default-features = false }
53-
webpki = { package = "rustls-webpki", version = "0.101", features = ["alloc", "std"] }
53+
webpki = { package = "rustls-webpki", version = "0.102", features = ["ring", "alloc", "std"] }
5454
once_cell = "1.9"
5555
android_logger = { version = "0.13", optional = true } # Only used during testing.
5656

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

6161
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
6262
core-foundation = "0.9"

src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,26 +52,26 @@ pub use tests::ffi::*;
5252
///
5353
/// If you require more control over the rustls `ClientConfig`, you can
5454
/// instantiate a [Verifier] with [Verifier::default] and then use it
55-
/// with [rustls::ConfigBuilder::with_custom_certificate_verifier].
55+
/// with [rustls::ConfigBuilder::dangerous::with_custom_certificate_verifier].
5656
///
5757
/// Refer to the crate level documentation to see what platforms
5858
/// are currently supported.
5959
pub fn tls_config() -> ClientConfig {
60-
rustls::ClientConfig::builder()
61-
.with_safe_defaults()
60+
ClientConfig::builder()
61+
.dangerous()
6262
.with_custom_certificate_verifier(verifier_for_testing())
6363
.with_no_client_auth()
6464
}
6565

6666
/// Exposed for test usage. Don't use this, use [tls_config] instead.
6767
///
6868
/// This verifier must be exactly equivalent to the verifier used in the `ClientConfig` returned by [tls_config].
69-
pub(crate) fn verifier_for_testing() -> Arc<dyn rustls::client::ServerCertVerifier> {
69+
pub(crate) fn verifier_for_testing() -> Arc<dyn rustls::client::danger::ServerCertVerifier> {
7070
Arc::new(Verifier::new())
7171
}
7272

7373
/// Exposed for debugging customer certificate issues. Don't use this, use [tls_config] instead.
7474
#[cfg(feature = "dbg")]
75-
pub fn verifier_for_dbg(root: &[u8]) -> Arc<dyn rustls::client::ServerCertVerifier> {
75+
pub fn verifier_for_dbg(root: &[u8]) -> Arc<dyn rustls::client::danger::ServerCertVerifier> {
7676
Arc::new(Verifier::new_with_fake_root(root))
7777
}

src/tests/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ pub fn assert_cert_error_eq<E: StdError + PartialEq + 'static>(
3939
if let Err(InvalidCertificate(CertificateError::Other(err))) = &expected {
4040
let expected_err = expected_err.expect("error not provided for `Other` case handling");
4141
let err: &E = err
42+
.0
4243
.downcast_ref()
4344
.expect("incorrect `Other` inner error kind");
4445
assert_eq!(err, expected_err);

0 commit comments

Comments
 (0)