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

23 lines
618 B
Rust
Raw Normal View History

2018-05-24 05:39:15 +02:00
// <ssl>
use actix_web::{server, App, HttpRequest, Responder};
use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
2018-07-21 14:21:41 +02:00
fn index(req: &HttpRequest) -> impl Responder {
2018-05-24 05:39:15 +02:00
"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>