Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/youyuanwu/tonic-tls
tonic grpc with various tls backends
https://github.com/youyuanwu/tonic-tls
grpc tokio tonic
Last synced: 29 days ago
JSON representation
tonic grpc with various tls backends
- Host: GitHub
- URL: https://github.com/youyuanwu/tonic-tls
- Owner: youyuanwu
- License: mit
- Created: 2024-11-24T01:29:00.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2024-12-20T22:15:16.000Z (about 2 months ago)
- Last Synced: 2024-12-29T14:51:35.320Z (about 1 month ago)
- Topics: grpc, tokio, tonic
- Language: Rust
- Homepage:
- Size: 49.8 KB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tonic-tls
![ci](https://github.com/youyuanwu/tonic-tls/actions/workflows/CI.yml/badge.svg)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://raw.githubusercontent.com/youyuanwu/tonic-tls/main/LICENSE)
[![Crates.io](https://img.shields.io/crates/v/tonic-tls)](https://crates.io/crates/tonic-tls)
[![Documentation](https://docs.rs/tonic-tls/badge.svg)](https://docs.rs/tonic-tls)
[![codecov](https://codecov.io/gh/youyuanwu/tonic-tls/graph/badge.svg?token=770RTTJ6R4)](https://codecov.io/gh/youyuanwu/tonic-tls)`tonic-tls` provides various tls backend plugins for grpc crate [tonic](https://github.com/hyperium/tonic).
* [native-tls](https://github.com/sfackler/rust-native-tls)
* [rustls](https://github.com/rustls/rustls)
* [openssl](https://github.com/sfackler/rust-openssl)
* [schannel](https://github.com/steffengy/schannel-rs)## Get Started
Add to Cargo.toml of your project.
Choose openssl backend:
```toml
tonic-tls = { version="*" , default-features = false, features = ["openssl"] }
# change features to "rustls" etc to enable other backends.
```## Examples
For full examples see [examples](./tonic-tls-tests/examples/)
```rs
// 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();
}
``````rs
// 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();
}
```# License
This project is licensed under the MIT license.