57 releases

new 0.20.0 Oct 16, 2020
0.14.0 Jul 5, 2020
0.13.0 Feb 23, 2020
0.12.1 Dec 8, 2019
0.1.6 Mar 31, 2017

#10 in Asynchronous

Download history 46776/week @ 2020-06-30 47122/week @ 2020-07-07 47208/week @ 2020-07-14 48453/week @ 2020-07-21 50472/week @ 2020-07-28 54098/week @ 2020-08-04 58606/week @ 2020-08-11 61408/week @ 2020-08-18 60287/week @ 2020-08-25 56651/week @ 2020-09-01 67642/week @ 2020-09-08 63533/week @ 2020-09-15 58076/week @ 2020-09-22 59832/week @ 2020-09-29 57982/week @ 2020-10-06 59149/week @ 2020-10-13

248,221 downloads per month
Used in 804 crates (87 directly)

MIT/Apache

41KB
1K SLoC

tokio-rustls

github actions crates license license docs.rs

Asynchronous TLS/SSL streams for Tokio using Rustls.

Basic Structure of a Client

use webpki::DNSNameRef;
use tokio_rustls::{ TlsConnector, rustls::ClientConfig };

// ...

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?;

// ...

Client Example Program

See examples/client. You can run it with:

cd examples/client
cargo run -- hsts.badssl.com

Server Example Program

See examples/server. You can run it with:

cd examples/server
cargo run -- 127.0.0.1 --cert mycert.der --key mykey.der

License & Origin

This project is licensed under either of

at your option.

This started as a fork of tokio-tls.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in tokio-rustls by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~9.5MB
~240K SLoC