Crates.io | tonic-tls |
lib.rs | tonic-tls |
version | |
source | src |
created_at | 2024-11-27 05:15:48.722368 |
updated_at | 2024-12-04 06:30:14.539018 |
description | Tls wrappers for tonic. |
homepage | |
repository | https://github.com/youyuanwu/tonic-tls |
max_upload_size | |
id | 1462678 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
tonic-tls
provides various tls backend plugins for grpc crate tonic.
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.
For full examples see examples
// Server example for openssl:
async fn run_openssl_tonic_server(
tcp_s: tonic::transport::server::TcpIncoming,
tls_acceptor: openssl::ssl::SslAcceptor,
) {
let incoming = tonic_tls::openssl::incoming(tcp_s, tls_acceptor);
let greeter = Greeter {};
tonic::transport::Server::builder()
.add_service(helloworld::greeter_server::GreeterServer::new(greeter))
.serve_with_incoming(incoming)
.await
.unwrap();
}
// client example for openssl:
async fn connect_tonic_channel(ssl_conn: openssl::ssl::SslConnector) {
let ch: tonic::transport::Channel= tonic_tls::new_endpoint()
.connect_with_connector(tonic_tls::openssl::connector(
"https://localhost:12345".parse().unwrap(),
ssl_conn,
"localhost".to_string(),
))
.await.unwrap();
}
This project is licensed under the MIT license.