diff --git a/Cargo.toml b/Cargo.toml index 1831be3ec..5e0cdb241 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -86,7 +86,7 @@ __tls = ["dep:rustls-pemfile", "tokio/io-util"] # Enables common rustls code. # Equivalent to rustls-tls-manual-roots but shorter :) -__rustls = ["dep:hyper-rustls", "dep:tokio-rustls", "dep:rustls", "__tls", "dep:rustls-pemfile", "rustls-pki-types"] +__rustls = ["dep:hyper-rustls", "dep:tokio-rustls", "dep:rustls", "__tls", "dep:rustls-pemfile", "dep:rustls-pki-types"] # When enabled, disable using the cached SYS_PROXIES. __internal_proxy_sys_no_cache = [] @@ -134,10 +134,10 @@ native-tls-crate = { version = "0.2.10", optional = true, package = "native-tls" tokio-native-tls = { version = "0.3.0", optional = true } # rustls-tls -hyper-rustls = { version = "0.26.0", default-features = false, optional = true } -rustls = { version = "0.22.2", optional = true } +hyper-rustls = { version = "0.27.0", default-features = false, optional = true, features = ["http1", "http2", "native-tokio", "ring", "tls12"] } +rustls = { version = "0.23.4", optional = true, default-features = false, features = ["std", "ring", "tls12"] } rustls-pki-types = { version = "1.1.0", features = ["alloc"] ,optional = true } -tokio-rustls = { version = "0.25", optional = true } +tokio-rustls = { version = "0.26", optional = true, default-features = false, features = ["ring", "tls12"] } webpki-roots = { version = "0.26.0", optional = true } rustls-native-certs = { version = "0.7", optional = true } diff --git a/src/async_impl/client.rs b/src/async_impl/client.rs index 22519f535..1930eff59 100644 --- a/src/async_impl/client.rs +++ b/src/async_impl/client.rs @@ -565,10 +565,17 @@ impl ClientBuilder { return Err(crate::error::builder("empty supported tls versions")); } + // Allow user to have installed a runtime default. + // If not, we use ring. + let provider = rustls::crypto::CryptoProvider::get_default() + .map(|arc| arc.clone()) + .unwrap_or_else(|| Arc::new(rustls::crypto::ring::default_provider())); + // Build TLS config - let config_builder = - rustls::ClientConfig::builder_with_protocol_versions(&versions) - .with_root_certificates(root_cert_store); + let config_builder = rustls::ClientConfig::builder_with_provider(provider) + .with_protocol_versions(&versions) + .map_err(|_| crate::error::builder("invalid TLS versions"))? + .with_root_certificates(root_cert_store); // Finalize TLS config let mut tls = if let Some(id) = config.identity {