1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-01-18 13:51:50 +01:00
actix-web/guide/src/qs_13.md
2018-01-13 11:17:48 -08:00

1.4 KiB

HTTP/2.0

Actix web automatically upgrades connection to HTTP/2.0 if possible.

Negotiation

HTTP/2.0 protocol over tls without prior knowledge requires tls alpn. At the moment only rust-openssl has support. Turn on alpn feature to enable alpn negotiation. With enable alpn feature HttpServer provides serve_tls method.

[dependencies]
actix-web = { git = "https://github.com/actix/actix-web", features=["alpn"] }
use std::fs::File;
use actix_web::*;

fn main() {
    let mut file = File::open("identity.pfx").unwrap();
    let mut pkcs12 = vec![];
    file.read_to_end(&mut pkcs12).unwrap();
    let pkcs12 = Pkcs12::from_der(&pkcs12).unwrap().parse("12345").unwrap();

    HttpServer::new(
        || Application::new()
            .resource("/index.html", |r| r.f(index)))
        .bind("127.0.0.1:8080").unwrap();
        .serve_ssl(pkcs12).unwrap();
}

Upgrade to HTTP/2.0 schema described in rfc section 3.2 is not supported. Starting HTTP/2 with prior knowledge is supported for both clear text connection and tls connection. rfc section 3.4

Please check example for concrete example.