mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-26 06:57:43 +02:00
actix-web: Add rustls 0.23 (#3363)
* Fix type confusion in some scenarios When the feature for rustls 0.22 is enabled, and rustls 0.23 is also present in a project, there suddently exist multiple paths for errors when building middleware chains due to the use of two consecutive `?` operators without specifying the intermediate error type. This commit addresses the issue by removing the first `?`, so that the first error type will always be known, and the second `?` always has a well defined implementation. * Add CHANGES entry about type confusion * actix-http: add rustls 0.23 support * actix-http: update ws example, tests for rustls 0.23 * actix-http: add rustls 0.23 to changelog * Update comments to mention 0.23 instead of 0.22 * awc: add rustls 0.23 support This also fixes certificate lookup when native-roots is enabled for rustls 0.22. * awc: update changelog for rustls 0.23 * awc: Add base rustls-0_23 feature without roots to better enable custom config * actix-test: add rustls-0.23 * actix-test: add rustls 0.23 to changelog * awc: update changelog with rustls 0.23 tweaks * actix-web: add rustls 0.23 * Add rustls-0_23 to CI * Update tls_rustls.rs * review nits * review nits part 2 * fix doc test --------- Co-authored-by: Rob Ede <robjtede@icloud.com>
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
- Add `TestServerConfig::rustls_0_23()` method for Rustls v0.23 support behind new `rustls-0_23` crate feature.
|
||||
- Minimum supported Rust version (MSRV) is now 1.72.
|
||||
- Various types from `awc`, such as `ClientRequest` and `ClientResponse`, are now re-exported.
|
||||
|
||||
|
@ -29,6 +29,8 @@ rustls-0_20 = ["tls-rustls-0_20", "actix-http/rustls-0_20", "awc/rustls-0_20"]
|
||||
rustls-0_21 = ["tls-rustls-0_21", "actix-http/rustls-0_21", "awc/rustls-0_21"]
|
||||
# TLS via Rustls v0.22
|
||||
rustls-0_22 = ["tls-rustls-0_22", "actix-http/rustls-0_22", "awc/rustls-0_22-webpki-roots"]
|
||||
# TLS via Rustls v0.23
|
||||
rustls-0_23 = ["tls-rustls-0_23", "actix-http/rustls-0_23", "awc/rustls-0_23-webpki-roots"]
|
||||
|
||||
# TLS via OpenSSL
|
||||
openssl = ["tls-openssl", "actix-http/openssl", "awc/openssl"]
|
||||
@ -53,4 +55,5 @@ tls-openssl = { package = "openssl", version = "0.10.55", optional = true }
|
||||
tls-rustls-0_20 = { package = "rustls", version = "0.20", optional = true }
|
||||
tls-rustls-0_21 = { package = "rustls", version = "0.21", optional = true }
|
||||
tls-rustls-0_22 = { package = "rustls", version = "0.22", optional = true }
|
||||
tls-rustls-0_23 = { package = "rustls", version = "0.23", default-features = false, optional = true }
|
||||
tokio = { version = "1.24.2", features = ["sync"] }
|
||||
|
@ -145,6 +145,8 @@ where
|
||||
StreamType::Rustls021(_) => true,
|
||||
#[cfg(feature = "rustls-0_22")]
|
||||
StreamType::Rustls022(_) => true,
|
||||
#[cfg(feature = "rustls-0_23")]
|
||||
StreamType::Rustls023(_) => true,
|
||||
};
|
||||
|
||||
// run server in separate orphaned thread
|
||||
@ -371,6 +373,48 @@ where
|
||||
.rustls_0_22(config.clone())
|
||||
}),
|
||||
},
|
||||
#[cfg(feature = "rustls-0_23")]
|
||||
StreamType::Rustls023(config) => match cfg.tp {
|
||||
HttpVer::Http1 => builder.listen("test", tcp, move || {
|
||||
let app_cfg =
|
||||
AppConfig::__priv_test_new(false, local_addr.to_string(), local_addr);
|
||||
|
||||
let fac = factory()
|
||||
.into_factory()
|
||||
.map_err(|err| err.into().error_response());
|
||||
|
||||
HttpService::build()
|
||||
.client_request_timeout(timeout)
|
||||
.h1(map_config(fac, move |_| app_cfg.clone()))
|
||||
.rustls_0_23(config.clone())
|
||||
}),
|
||||
HttpVer::Http2 => builder.listen("test", tcp, move || {
|
||||
let app_cfg =
|
||||
AppConfig::__priv_test_new(false, local_addr.to_string(), local_addr);
|
||||
|
||||
let fac = factory()
|
||||
.into_factory()
|
||||
.map_err(|err| err.into().error_response());
|
||||
|
||||
HttpService::build()
|
||||
.client_request_timeout(timeout)
|
||||
.h2(map_config(fac, move |_| app_cfg.clone()))
|
||||
.rustls_0_23(config.clone())
|
||||
}),
|
||||
HttpVer::Both => builder.listen("test", tcp, move || {
|
||||
let app_cfg =
|
||||
AppConfig::__priv_test_new(false, local_addr.to_string(), local_addr);
|
||||
|
||||
let fac = factory()
|
||||
.into_factory()
|
||||
.map_err(|err| err.into().error_response());
|
||||
|
||||
HttpService::build()
|
||||
.client_request_timeout(timeout)
|
||||
.finish(map_config(fac, move |_| app_cfg.clone()))
|
||||
.rustls_0_23(config.clone())
|
||||
}),
|
||||
},
|
||||
}
|
||||
.expect("test server could not be created");
|
||||
|
||||
@ -447,6 +491,8 @@ enum StreamType {
|
||||
Rustls021(tls_rustls_0_21::ServerConfig),
|
||||
#[cfg(feature = "rustls-0_22")]
|
||||
Rustls022(tls_rustls_0_22::ServerConfig),
|
||||
#[cfg(feature = "rustls-0_23")]
|
||||
Rustls023(tls_rustls_0_23::ServerConfig),
|
||||
}
|
||||
|
||||
/// Create default test server config.
|
||||
@ -537,6 +583,13 @@ impl TestServerConfig {
|
||||
self
|
||||
}
|
||||
|
||||
/// Accepts secure connections via Rustls v0.23.
|
||||
#[cfg(feature = "rustls-0_23")]
|
||||
pub fn rustls_0_23(mut self, config: tls_rustls_0_23::ServerConfig) -> Self {
|
||||
self.stream = StreamType::Rustls023(config);
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets client timeout for first request.
|
||||
pub fn client_request_timeout(mut self, dur: Duration) -> Self {
|
||||
self.client_request_timeout = dur;
|
||||
|
Reference in New Issue
Block a user