Add rustls-tls-manual-roots feature to allow callers to specify roots

Now, callers have more control over the set of roots.

Note that, due to cargo unification, other dependencies in the
dependency tree might enable rustls-tls-webpki-roots
or rustls-tls.
This will affect connections initiated by code that explicitly
enabled rustls-tls-manual-roots.

So for now, the choice is done once per entire cargo
dependency graph. If people want more precise control
over things, they can add methods that allow controlling
this on a per-connection level. Even if such methods
are available, the *-manual-roots feature will still be
helpful with eliminating the webpki-roots dependency
for those cargo graphs where there is no unification.
This commit is contained in:
est31
2020-10-16 19:24:41 +02:00
committed by Sean McArthur
parent 4fe07d81cf
commit 3ea9f92f24
9 changed files with 71 additions and 56 deletions

View File

@@ -1,6 +1,6 @@
#![cfg(not(target_arch = "wasm32"))]
#[cfg(feature = "__tls")]
#[cfg(all(feature = "__tls", not(feature = "rustls-tls-manual-roots")))]
#[tokio::test]
async fn test_badssl_modern() {
let text = reqwest::Client::builder()
@@ -18,7 +18,7 @@ async fn test_badssl_modern() {
assert!(text.contains("<title>mozilla-modern.badssl.com</title>"));
}
#[cfg(feature = "rustls-tls")]
#[cfg(feature = "rustls-tls-webpki-roots")]
#[tokio::test]
async fn test_rustls_badssl_modern() {
let text = reqwest::Client::builder()

View File

@@ -161,7 +161,7 @@ async fn body_pipe_response() {
assert_eq!(res2.status(), reqwest::StatusCode::OK);
}
#[cfg(any(feature = "native-tls", feature = "rustls-tls",))]
#[cfg(any(feature = "native-tls", feature = "__rustls",))]
#[test]
fn use_preconfigured_tls_with_bogus_backend() {
struct DefinitelyNotTls;
@@ -187,7 +187,7 @@ fn use_preconfigured_native_tls_default() {
.expect("preconfigured default tls");
}
#[cfg(feature = "rustls-tls")]
#[cfg(feature = "__rustls")]
#[test]
fn use_preconfigured_rustls_default() {
extern crate rustls;