Skip to content

tonic grpc with various tls backends

License

Notifications You must be signed in to change notification settings

adburch/tonic-tls

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tonic-tls

ci License: MIT Crates.io Documentation

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:
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();
}

License

This project is licensed under the MIT license.

About

tonic grpc with various tls backends

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%