1
0
mirror of https://github.com/actix/actix-website synced 2024-11-25 17:22:42 +01:00
actix-website/examples/server/src/ssl.rs
2018-07-21 05:21:41 -07:00

23 lines
618 B
Rust

// <ssl>
use actix_web::{server, App, HttpRequest, Responder};
use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
fn index(req: &HttpRequest) -> impl Responder {
"Welcome!"
}
fn main() {
// load ssl keys
let mut builder = SslAcceptor::mozilla_intermediate(SslMethod::tls()).unwrap();
builder
.set_private_key_file("key.pem", SslFiletype::PEM)
.unwrap();
builder.set_certificate_chain_file("cert.pem").unwrap();
server::new(|| App::new().resource("/index.html", |r| r.f(index)))
.bind_ssl("127.0.0.1:8080", builder)
.unwrap()
.run();
}
// </ssl>