#tokio #client #rustls

tokio-rustls

Asynchronous TLS/SSL streams for Tokio using Rustls

52 releases

✓ Uses Rust 2018 edition

0.13.0 Feb 23, 2020
0.12.1 Dec 8, 2019
0.12.0 Nov 27, 2019
0.10.3 Jan 7, 2020
0.1.6 Mar 31, 2017

#8 in Asynchronous

Download history 29205/week @ 2019-12-10 26462/week @ 2019-12-17 13827/week @ 2019-12-24 19346/week @ 2019-12-31 31998/week @ 2020-01-07 34240/week @ 2020-01-14 40152/week @ 2020-01-21 40717/week @ 2020-01-28 35864/week @ 2020-02-04 30669/week @ 2020-02-11 29972/week @ 2020-02-18 34788/week @ 2020-02-25 33703/week @ 2020-03-03 35096/week @ 2020-03-10 32889/week @ 2020-03-17 27697/week @ 2020-03-24

126,364 downloads per month
Used in 565 crates (54 directly)

MIT/Apache

47KB
1K SLoC

tokio-rustls

github actions codecov 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
~247K SLoC