10 stable releases

2.1.4 Dec 16, 2021
2.1.3 Apr 16, 2021
2.1.1 Mar 9, 2021
2.1.0 Feb 24, 2021
1.0.2 Nov 12, 2020
Download history 2936/week @ 2021-10-06 2728/week @ 2021-10-13 2642/week @ 2021-10-20 2592/week @ 2021-10-27 3269/week @ 2021-11-03 2746/week @ 2021-11-10 4516/week @ 2021-11-17 3558/week @ 2021-11-24 3669/week @ 2021-12-01 3504/week @ 2021-12-08 3553/week @ 2021-12-15 1197/week @ 2021-12-22 2558/week @ 2021-12-29 2774/week @ 2022-01-05 2025/week @ 2022-01-12 3835/week @ 2022-01-19

11,372 downloads per month
Used in 2 crates (via hyper-boring)

MIT/Apache

14MB
430K SLoC

GNU Style Assembly 190K SLoC // 0.0% comments C++ 88K SLoC // 0.2% comments C 76K SLoC // 0.2% comments Assembly 62K SLoC // 0.0% comments Rust 14K SLoC // 0.0% 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

~2–4.5MB
~79K SLoC