#tokio #rustls

tokio-rustls

Asynchronous TLS/SSL streams for Tokio using Rustls

61 releases (16 breaking)

0.22.0 Dec 24, 2020
0.21.0 Nov 25, 2020
0.14.0 Jul 5, 2020
0.13.0 Feb 23, 2020
0.1.6 Mar 31, 2017
Download history 56108/week @ 2020-10-05 63570/week @ 2020-10-12 68659/week @ 2020-10-19 73493/week @ 2020-10-26 70451/week @ 2020-11-02 65833/week @ 2020-11-09 81976/week @ 2020-11-16 66860/week @ 2020-11-23 74752/week @ 2020-11-30 73622/week @ 2020-12-07 78712/week @ 2020-12-14 47420/week @ 2020-12-21 46107/week @ 2020-12-28 81487/week @ 2021-01-04 87247/week @ 2021-01-11 80183/week @ 2021-01-18

290,466 downloads per month
Used in 917 crates (99 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

~9MB
~225K SLoC