#tokio #client #rustls

tokio-rustls

Asynchronous TLS/SSL streams for Tokio using Rustls

47 releases

✓ Uses Rust 2018 edition

0.12.0-alpha.8 Nov 7, 2019
0.12.0-alpha.5 Oct 23, 2019
0.10.0-alpha.4 Jul 25, 2019
0.10.0-alpha.1 Mar 26, 2019
0.1.6 Mar 31, 2017

#9 in Asynchronous

Download history 11960/week @ 2019-07-25 11723/week @ 2019-08-01 13353/week @ 2019-08-08 14813/week @ 2019-08-15 14675/week @ 2019-08-22 15576/week @ 2019-08-29 18227/week @ 2019-09-05 18443/week @ 2019-09-12 19711/week @ 2019-09-19 22999/week @ 2019-09-26 28910/week @ 2019-10-03 26954/week @ 2019-10-10 29897/week @ 2019-10-17 27857/week @ 2019-10-24 23237/week @ 2019-10-31

91,566 downloads per month
Used in 390 crates (36 directly)

MIT/Apache

39KB
898 lines

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();

TcpStream::connect(&addr)
	.and_then(move |socket| config.connect(dnsname, socket))

// ...

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

~7MB
~210K SLoC