mirror of
https://github.com/actix/actix-website
synced 2024-11-30 19:14:36 +01:00
1.5 KiB
1.5 KiB
title | menu | weight |
---|---|---|
HTTP/2.0 | docs_proto | 250 |
如果可能actix-web
自动升级到HTTP/2.0的连接。
协议
HTTP/2.0 protocol over tls without prior knowledge requires tls alpn.
目前,只有
rust-openssl
支持
alpn
协议需要启用该功能。启用后,HttpServer提供 serve_tls方法。
serve_tls method.
[dependencies]
actix-web = { version = "{{< actix-version "actix-web" >}}", features = ["alpn"] }
openssl = { version = "0.10", features = ["v110"] }
use std::fs::File;
use actix_web::*;
use openssl::ssl::{SslMethod, SslAcceptor, SslFiletype};
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();
HttpServer::new(
|| App::new()
.resource("/index.html", |r| r.f(index)))
.bind("127.0.0.1:8080").unwrap();
.serve_ssl(builder).unwrap();
}
不支持升级到rfc section 3.2 节中描述的HTTP/2.0模式 。明文连接和tls连接都支持HTTP/2 with prior knowledge启动,rfc section 3.4
查看具体示例examples/tls.