#tokio #client #rustls

tokio-rustls

Asynchronous TLS/SSL streams for Tokio using Rustls

51 releases

✓ Uses Rust 2018 edition

0.12.2 Jan 7, 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

#7 in Asynchronous

Download history 26089/week @ 2019-10-07 29057/week @ 2019-10-14 29274/week @ 2019-10-21 24724/week @ 2019-10-28 26795/week @ 2019-11-04 27146/week @ 2019-11-11 26487/week @ 2019-11-18 25379/week @ 2019-11-25 27841/week @ 2019-12-02 29679/week @ 2019-12-09 27578/week @ 2019-12-16 13838/week @ 2019-12-23 18586/week @ 2019-12-30 30837/week @ 2020-01-06 33094/week @ 2020-01-13

108,705 downloads per month
Used in 450 crates (49 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

~8MB
~227K SLoC