54 releases

✓ Uses Rust 2018 edition

0.13.1 May 19, 2020
0.13.0 Feb 23, 2020
0.12.3 May 19, 2020
0.12.2 Jan 7, 2020
0.1.6 Mar 31, 2017

#6 in Asynchronous

Download history 33744/week @ 2020-02-06 30093/week @ 2020-02-13 31518/week @ 2020-02-20 34862/week @ 2020-02-27 33959/week @ 2020-03-05 35378/week @ 2020-03-12 30776/week @ 2020-03-19 33240/week @ 2020-03-26 32836/week @ 2020-04-02 31921/week @ 2020-04-09 38056/week @ 2020-04-16 38433/week @ 2020-04-23 40452/week @ 2020-04-30 39792/week @ 2020-05-07 46250/week @ 2020-05-14 37218/week @ 2020-05-21

150,962 downloads per month
Used in 627 crates (66 directly)

MIT/Apache

47KB
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

~9MB
~248K SLoC