6 stable releases

4.11.1 Nov 3, 2024
4.10.3 Nov 3, 2024
4.10.2 Sep 22, 2024
4.9.1 Aug 12, 2024
2.1.5 Nov 1, 2024

#958 in Network programming

Download history 870/week @ 2024-08-16 261/week @ 2024-08-23 179/week @ 2024-08-30 264/week @ 2024-09-06 179/week @ 2024-09-13 769/week @ 2024-09-20 299/week @ 2024-09-27 370/week @ 2024-10-04 397/week @ 2024-10-11 441/week @ 2024-10-18 380/week @ 2024-10-25 765/week @ 2024-11-01 416/week @ 2024-11-08 294/week @ 2024-11-15 141/week @ 2024-11-22 100/week @ 2024-11-29

1,026 downloads per month
Used in hyper-rboring

MIT/Apache

16MB
463K SLoC

GNU Style Assembly 206K SLoC // 0.0% comments C++ 98K SLoC // 0.2% comments C 78K SLoC // 0.2% comments Assembly 63K SLoC // 0.0% comments Rust 17K SLoC // 0.0% comments Bazel 1K SLoC

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

~2–11MB
~113K SLoC