pub fn tls_config() -> ClientConfig
๐Deprecated since 0.4.0: use the
ConfigVerifierExt
insteadExpand description
Creates and returns a rustls
configuration that verifies TLS
certificates in the best way for the underlying OS platform, using
safe defaults for the rustls
configuration.
ยงExample
This example shows how to use the custom verifier with the reqwest
crate:
โ
#[tokio::main]
use rustls_platform_verifier::ConfigVerifierExt;
async fn main() {
let client = ClientBuilder::new()
.use_preconfigured_tls(ClientConfig::with_platform_verifier())
.build()
.expect("nothing should fail");
let _response = client.get("https://example.com").send().await;
}
Important: You must ensure that your reqwest
version is using the same Rustls
version as this crate or it will panic when downcasting the &dyn Any
verifier.
If you require more control over the rustls ClientConfig
, you can import the
BuilderVerifierExt
trait and call .with_platform_verifier()
on the ConfigBuilder
.
Refer to the crate level documentation to see what platforms are currently supported.