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)
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
async fn main() {
    let app = Router::new().route("/", get(|| async { "Hello, world!" }));

    let config = RustlsConfig::from_pem_file(
        "examples/self-signed-certs/cert.pem",
        "examples/self-signed-certs/key.pem",
    )
    .await
    .unwrap();

    let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
    let listener = TcpListener::bind(addr).unwrap();
    println!("listening on {}", addr);
    axum_server::from_tcp_rustls(listener, config)
        .serve(app.into_make_service())
        .await
        .unwrap();
}