Expand description
A tls adaptor for tonic.
Supports various tls backend:
- native_tls in mod [native].
- openssl in mod [openssl].
- rustls in mod [rustls].
- schannel in mod [schannel].
For full examples see examples. Server example for openssl:
§Examples
Server example:
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:
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()
}Constants§
- ALPN_H2
- A const that contains the on the wire
h2alpn value to pass to tls backends.
Traits§
- TlsAcceptor
- Trait for abstracting tls backend’s stream accept impl. Not intended to be used directly by applications. To add a new tls backend, this trait needs to be implemented, and the implementation needs to be passed to incoming_inner.
- TlsConnector
- Not intended to be used by applications directly. To add a new tls backend, implement this and pass it into connector_inner.
Functions§
- connector_
inner - Not intended to be used by applications directly. Applications should use the tls backend api, for example [super::openssl::connector]
- incoming_
inner - Wraps the incoming stream into a tls stream. Use this only when implementing tls backends. For applications, use a tls backend instead. For example incomming.
Type Aliases§
- Error
- Common boxed error.