42 stable releases (4 major)

5.0.0 Feb 10, 2026
5.0.0-alpha.1 Jan 21, 2026
4.22.0 May 6, 2026
4.19.0 Sep 5, 2025
1.0.2 Nov 12, 2020

#4 in #tokio-stream

Download history 31060/week @ 2026-01-16 31184/week @ 2026-01-23 37720/week @ 2026-01-30 28877/week @ 2026-02-06 27366/week @ 2026-02-13 36540/week @ 2026-02-20 39259/week @ 2026-02-27 42085/week @ 2026-03-06 31760/week @ 2026-03-13 38105/week @ 2026-03-20 36097/week @ 2026-03-27 30048/week @ 2026-04-03 35292/week @ 2026-04-10 34350/week @ 2026-04-17 35504/week @ 2026-04-24 33159/week @ 2026-05-01

144,402 downloads per month
Used in 12 crates (10 directly)

MIT/Apache

22MB
640K SLoC

C++ 205K SLoC // 0.1% comments GNU Style Assembly 194K SLoC // 0.0% comments Assembly 64K SLoC // 0.0% comments Go 64K SLoC // 0.1% comments Perl 56K SLoC // 0.1% comments Bitbake 33K SLoC // 0.0% comments Rust 21K SLoC // 0.0% comments Bazel 3K SLoC // 0.0% comments C 14 SLoC // 0.5% comments

tokio-boring

An implementation of SSL streams for Tokio built on top of the BoringSSL.

Documentation

Usage

First, add this to your Cargo.toml:

[dependencies]
tokio-boring = "1.0.0"

Then, use either accept or connect as appropriate.

use boring::ssl;
use tokio::net::TcpListener;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let listener = TcpListener::bind("127.0.0.1:8080").await?;
    let (tcp_stream, _addr) = listener.accept().await?;

    let server = ssl::SslMethod::tls_server();
    let mut ssl_builder = boring::ssl::SslAcceptor::mozilla_modern(server)?;
    ssl_builder.set_default_verify_paths()?;
    ssl_builder.set_verify(ssl::SslVerifyMode::PEER);
    let acceptor = ssl_builder.build();
    let _ssl_stream = tokio_boring::accept(&acceptor, tcp_stream).await?;
    Ok(())
}

This library is an implementation of TLS streams using BoringSSL for negotiating the connection. Each TLS stream implements the Read and Write traits to interact and interoperate with the rest of the futures I/O ecosystem. Client connections initiated from this crate verify hostnames automatically and by default.

tokio-boring exports this ability through accept and connect. accept should be used by servers, and connect by clients. These augment the functionality provided by the boring crate, on which this crate is built. Configuration of TLS parameters is still primarily done through the boring crate.

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Serde by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Accolades

The project is based on a fork of tokio-openssl.

Dependencies

~1.8–5MB
~88K SLoC