Function from_tcp_rustls

Source
pub fn from_tcp_rustls(
    listener: TcpListener,
    config: RustlsConfig,
) -> Server<RustlsAcceptor>
Available on crate feature tls-rustls only.
Expand description

Create a tls server from existing std::net::TcpListener.

Examples found in repository?
examples/from_std_listener_rustls.rs (line 24)
11async fn main() {
12    let app = Router::new().route("/", get(|| async { "Hello, world!" }));
13
14    let config = RustlsConfig::from_pem_file(
15        "examples/self-signed-certs/cert.pem",
16        "examples/self-signed-certs/key.pem",
17    )
18    .await
19    .unwrap();
20
21    let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
22    let listener = TcpListener::bind(addr).unwrap();
23    println!("listening on {}", addr);
24    hyper_serve::from_tcp_rustls(listener, config)
25        .serve(app.into_make_service())
26        .await
27        .unwrap();
28}