Skip to content

Commit 934bc84

Browse files
authored
chore: separate rustls and rustls-no-provider features (#2903)
1 parent 19ca5d4 commit 934bc84

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ default-tls = ["rustls"]
4444

4545
http2 = ["h2", "hyper/http2", "hyper-util/http2", "hyper-rustls?/http2"]
4646

47-
rustls = ["rustls-no-provider", "__rustls-aws-lc-rs"]
47+
rustls = ["__rustls-aws-lc-rs", "dep:rustls-platform-verifier", "__rustls"]
4848
rustls-no-provider = ["dep:rustls-platform-verifier", "__rustls"]
4949

5050
native-tls = ["dep:hyper-tls", "dep:native-tls-crate", "__tls", "dep:tokio-native-tls"]

tests/badssl.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ async fn test_badssl_no_built_in_roots() {
5353
assert!(result.is_err());
5454
}
5555

56-
#[cfg(any(feature = "native-tls", feature = "rustls"))]
56+
#[cfg(any(feature = "native-tls"))]
5757
#[tokio::test]
5858
async fn test_badssl_wrong_host() {
5959
let text = reqwest::Client::builder()
60+
.tls_backend_native()
6061
.tls_danger_accept_invalid_hostnames(true)
6162
.no_proxy()
6263
.build()
@@ -72,6 +73,7 @@ async fn test_badssl_wrong_host() {
7273
assert!(text.contains("<title>wrong.host.badssl.com</title>"));
7374

7475
let result = reqwest::Client::builder()
76+
.tls_backend_native()
7577
.tls_danger_accept_invalid_hostnames(true)
7678
.build()
7779
.unwrap()

tests/client.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,15 +351,19 @@ fn use_preconfigured_native_tls_default() {
351351
.expect("preconfigured default tls");
352352
}
353353

354-
#[cfg(feature = "__rustls")]
354+
#[cfg(feature = "rustls")] // needs a TLS provider
355355
#[test]
356356
fn use_preconfigured_rustls_default() {
357357
extern crate rustls;
358358

359359
let root_cert_store = rustls::RootCertStore::empty();
360-
let tls = rustls::ClientConfig::builder()
361-
.with_root_certificates(root_cert_store)
362-
.with_no_client_auth();
360+
let tls = rustls::ClientConfig::builder_with_provider(std::sync::Arc::new(
361+
rustls::crypto::aws_lc_rs::default_provider(),
362+
))
363+
.with_safe_default_protocol_versions()
364+
.unwrap()
365+
.with_root_certificates(root_cert_store)
366+
.with_no_client_auth();
363367

364368
reqwest::Client::builder()
365369
.use_preconfigured_tls(tls)

0 commit comments

Comments
 (0)