7 releases (breaking)

Uses new Rust 2024

0.6.0 Aug 11, 2025
0.5.0 Jul 13, 2025
0.4.0 May 24, 2025
0.3.0 Apr 4, 2025
0.1.0 Nov 27, 2024

#738 in Network programming

Download history 1069/week @ 2025-05-23 1443/week @ 2025-05-30 1460/week @ 2025-06-06 1720/week @ 2025-06-13 1182/week @ 2025-06-20 1531/week @ 2025-06-27 2407/week @ 2025-07-04 1311/week @ 2025-07-11 1852/week @ 2025-07-18 1912/week @ 2025-07-25 1577/week @ 2025-08-01 4062/week @ 2025-08-08 5347/week @ 2025-08-15 7926/week @ 2025-08-22 5661/week @ 2025-08-29 7484/week @ 2025-09-05

27,396 downloads per month
Used in 16 crates (3 directly)

MIT license

59KB
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 {
    endpoint.connect_with_connector(tonic_tls::openssl::TlsConnector::new(
        &endpoint,
        ssl_conn,
       "localhost".to_string(),
    )).await.unwrap()
}

License

This project is licensed under the MIT license.

Dependencies

~6–20MB
~291K SLoC