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
14,315 downloads per month
Used in 20 crates
(4 directly)
64KB
1K
SLoC
tonic-tls
tonic-tls provides various tls backend plugins for grpc crate tonic.
- native-tls
- rustls
- openssl
- schannel
- openssl-ktls Experimental
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