26 stable releases (3 major)

4.8.0 Jul 5, 2024
4.6.0 Apr 10, 2024
4.5.0 Feb 8, 2024
4.2.0 Dec 14, 2023
1.0.2 Nov 12, 2020

#1796 in Network programming

Download history 4428/week @ 2024-03-17 3299/week @ 2024-03-24 3155/week @ 2024-03-31 3516/week @ 2024-04-07 2923/week @ 2024-04-14 3426/week @ 2024-04-21 4356/week @ 2024-04-28 3103/week @ 2024-05-05 4296/week @ 2024-05-12 3739/week @ 2024-05-19 2875/week @ 2024-05-26 2966/week @ 2024-06-02 3471/week @ 2024-06-09 3520/week @ 2024-06-16 3908/week @ 2024-06-23 1307/week @ 2024-06-30

12,289 downloads per month
Used in 5 crates (4 directly)

MIT/Apache

27MB
742K SLoC

GNU Style Assembly 218K SLoC // 0.0% comments C++ 186K SLoC // 0.2% comments C 152K SLoC // 0.2% comments Assembly 63K SLoC // 0.0% comments Perl 56K SLoC // 0.1% comments Go 49K SLoC // 0.1% 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.5–6.5MB
~109K SLoC