75 releases

0.26.1 Dec 5, 2024
0.26.0 Mar 22, 2024
0.25.0 Dec 5, 2023
0.25.0-alpha.4 Nov 30, 2023
0.1.6 Mar 31, 2017

#3 in Asynchronous

Download history 2493997/week @ 2024-10-30 2490173/week @ 2024-11-06 2620811/week @ 2024-11-13 2512672/week @ 2024-11-20 2064169/week @ 2024-11-27 2611928/week @ 2024-12-04 2840718/week @ 2024-12-11 1933247/week @ 2024-12-18 1065525/week @ 2024-12-25 1872759/week @ 2025-01-01 2820187/week @ 2025-01-08 2692416/week @ 2025-01-15 2728123/week @ 2025-01-22 2886182/week @ 2025-01-29 3233721/week @ 2025-02-05 2507154/week @ 2025-02-12

11,842,795 downloads per month
Used in 5,296 crates (602 directly)

MIT/Apache

65KB
1.5K SLoC

tokio-rustls

github actions crates license license docs.rs

Asynchronous TLS/SSL streams for Tokio using Rustls.

Basic Structure of a Client

use rustls_pki_types::ServerName;
use std::sync::Arc;
use tokio::net::TcpStream;
use tokio_rustls::rustls::{ClientConfig, RootCertStore};
use tokio_rustls::TlsConnector;

// ...

let mut root_cert_store = RootCertStore::empty();
root_cert_store.extend(webpki_roots::TLS_SERVER_ROOTS.iter().cloned());
let config = ClientConfig::builder()
    .with_root_certificates(root_cert_store)
    .with_no_client_auth();
let connector = TlsConnector::from(Arc::new(config));
let dnsname = ServerName::try_from("www.rust-lang.org").unwrap();

let stream = TcpStream::connect(&addr).await?;
let mut stream = connector.connect(dnsname, stream).await?;

// ...

Client Example Program

See examples/client.rs. You can run it with:

cargo run --example client -- hsts.badssl.com

Server Example Program

See examples/server.rs. You can run it with:

cargo run --example server -- 127.0.0.1:8000 --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

~9–32MB
~734K SLoC

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy