diff --git a/src/async_impl/client.rs b/src/async_impl/client.rs
index 0552537..5cf3546 100644
--- a/src/async_impl/client.rs
+++ b/src/async_impl/client.rs
@@ -1,3 +1,5 @@
+#[cfg(feature = "__tls")]
+use std::any::Any;
use std::convert::TryInto;
use std::net::IpAddr;
use std::sync::Arc;
@@ -188,6 +190,7 @@ impl ClientBuilder {
}
}
+
Connector::new_default_tls(
tls,
proxies.clone(),
@@ -195,7 +198,25 @@ impl ClientBuilder {
config.local_address,
config.nodelay,
)?
- }
+ },
+ #[cfg(feature = "default-tls")]
+ TlsBackend::BuiltDefault(conn) => {
+ Connector::from_built_default(
+ conn,
+ proxies.clone(),
+ user_agent(&config.headers),
+ config.local_address,
+ config.nodelay)?
+ },
+ #[cfg(feature = "rustls-tls")]
+ TlsBackend::BuiltRustls(conn) => {
+ Connector::new_rustls_tls(
+ conn,
+ proxies.clone(),
+ user_agent(&config.headers),
+ config.local_address,
+ config.nodelay)?
+ },
#[cfg(feature = "rustls-tls")]
TlsBackend::Rustls => {
use crate::tls::NoVerifier;
@@ -229,7 +250,12 @@ impl ClientBuilder {
config.local_address,
config.nodelay,
)?
- }
+ },
+ TlsBackend::UnknownPreconfigured => {
+ return Err(crate::error::builder(
+ "Unknown TLS backend passed to `use_preconfigured_tls`"
+ ));
+ },
}
#[cfg(not(feature = "__tls"))]
@@ -711,6 +737,38 @@ impl ClientBuilder {
self.config.tls = TlsBackend::Rustls;
self
}
+
+ /// Use a preconfigured TLS backend.
+ ///
+ /// If the passed `Any` argument is not a TLS backend that reqwest
+ /// understands, the `ClientBuilder` will error when calling `build`.
+ #[cfg(feature = "__tls")]
+ pub fn use_preconfigured_tls(mut self, tls: impl Any) -> ClientBuilder {
+ let mut tls = Some(tls);
+ #[cfg(feature = "default-tls")]
+ {
+ if let Some(conn) = (&mut tls as &mut dyn Any).downcast_mut::