Skip to content

Commit 239f0b3

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 3bf8828 commit 239f0b3

File tree

11 files changed

+340
-300
lines changed

11 files changed

+340
-300
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.

rustls-platform-verifier/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,27 @@ cert-logging = ["base64"]
2929
docsrs = ["jni", "once_cell"]
3030

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

3838
[target.'cfg(target_os = "linux")'.dependencies]
39-
rustls-native-certs = "0.6"
39+
rustls-native-certs = "0.7"
4040
once_cell = "1.9"
41-
webpki = { package = "rustls-webpki", version = "0.101", features = ["alloc", "std"] }
41+
webpki = { package = "rustls-webpki", version = "0.102", features = ["ring", "alloc", "std"] }
4242

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

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

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

rustls-platform-verifier/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ pub use tests::ffi::*;
5353
///
5454
/// If you require more control over the rustls `ClientConfig`, you can
5555
/// instantiate a [Verifier] with [Verifier::default] and then use it
56-
/// with [rustls::ConfigBuilder::with_custom_certificate_verifier].
56+
/// with [rustls::ConfigBuilder::dangerous::with_custom_certificate_verifier].
5757
///
5858
/// Refer to the crate level documentation to see what platforms
5959
/// are currently supported.
6060
pub fn tls_config() -> ClientConfig {
61-
rustls::ClientConfig::builder()
62-
.with_safe_defaults()
61+
ClientConfig::builder()
62+
.dangerous()
6363
.with_custom_certificate_verifier(Arc::new(Verifier::new()))
6464
.with_no_client_auth()
6565
}
@@ -68,6 +68,6 @@ pub fn tls_config() -> ClientConfig {
6868
///
6969
/// This is not intended for production use, you should use [tls_config] instead.
7070
#[cfg(feature = "dbg")]
71-
pub fn verifier_for_dbg(root: &[u8]) -> Arc<dyn rustls::client::ServerCertVerifier> {
71+
pub fn verifier_for_dbg(root: &[u8]) -> Arc<dyn rustls::client::danger::ServerCertVerifier> {
7272
Arc::new(Verifier::new_with_fake_root(root))
7373
}

rustls-platform-verifier/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)