Module hyper_serve::tls_openssl

source ·
Available on crate feature tls-openssl only.
Expand description

Tls implementation using openssl

§Example

use axum::{routing::get, Router};
use hyper_serve::tls_openssl::OpenSSLConfig;
use std::net::SocketAddr;

#[tokio::main]
async fn main() {
    let app = Router::new().route("/", get(|| async { "Hello, world!" }));

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

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

Modules§

Structs§

Functions§