How to use tokio-rustls new api?
linsinn opened this issue · comments
There is no ClientConfig::new()
any more, how to use ClientConfig::builder()
to get the same result?
let mut config = ClientConfig::new();
config.root_store.add_server_trust_anchors(&webpki_roots::TLS_SERVER_ROOTS);
let config = TlsConnector::from(Arc::new(config));
let dnsname = DNSNameRef::try_from_ascii_str("www.rust-lang.org").unwrap();
let stream = TcpStream::connect(&addr).await?;
let mut stream = config.connect(dnsname, stream).await?;
Have a look at the example code:
https://github.com/tokio-rs/tls/blob/master/tokio-rustls/examples/client/src/main.rs