9 releases (breaking)

Uses new Rust 2024

new 0.7.0 Mar 7, 2026
0.6.1 Oct 17, 2025
0.6.0 Aug 11, 2025
0.5.0 Jul 13, 2025
0.2.0 Nov 29, 2024

#821 in Network programming

Download history 2484/week @ 2025-11-15 1159/week @ 2025-11-22 2632/week @ 2025-11-29 2701/week @ 2025-12-06 2998/week @ 2025-12-13 843/week @ 2025-12-20 327/week @ 2025-12-27 3993/week @ 2026-01-03 3010/week @ 2026-01-10 2839/week @ 2026-01-17 1407/week @ 2026-01-24 2509/week @ 2026-01-31 3164/week @ 2026-02-07 3594/week @ 2026-02-14 3986/week @ 2026-02-21 2992/week @ 2026-02-28

14,315 downloads per month
Used in 20 crates (4 directly)

MIT license

64KB
1K SLoC

tonic-tls

ci License: MIT Crates.io Documentation codecov

tonic-tls provides various tls backend plugins for grpc crate tonic.

Get Started

Add to Cargo.toml of your project. Choose openssl backend:

tonic-tls = { version="*" , default-features = false, features = ["openssl"] }
# change features to "rustls" etc to enable other backends.

Examples

For full examples see examples

// Server example for openssl:
use openssl::ssl::SslAcceptor;
use tonic_tls::openssl::TlsIncoming;
let addr = "127.0.0.1:1322".parse().unwrap();
let inc = TlsIncoming::new(TcpIncoming::bind(addr).unwrap(), acceptor);
Server::builder()
   .add_service(some_service)
   .serve_with_incoming(inc);
// Client example for openssl:
async fn connect_tonic_channel(
    endpoint: tonic::transport::Endpoint,
    ssl_conn: openssl::ssl::SslConnector
) -> tonic::transport::Channel {
    let transport = tonic_tls::TcpTransport::from_endpoint(&endpoint);
    endpoint.connect_with_connector(tonic_tls::openssl::TlsConnector::new(
        transport,
        ssl_conn,
       "localhost".to_string(),
    )).await.unwrap()
}

License

This project is licensed under the MIT license.

Dependencies

~10–28MB
~332K SLoC