1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-23 16:21:06 +01:00

test: update rustls for test_server

This commit is contained in:
Rob Ede 2024-02-04 03:30:16 +00:00
parent d9b31b80ac
commit f5f6132f94
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
2 changed files with 11 additions and 14 deletions

View File

@ -128,12 +128,12 @@ env_logger = "0.10"
flate2 = "1.0.13" flate2 = "1.0.13"
futures-util = { version = "0.3.17", default-features = false, features = ["std"] } futures-util = { version = "0.3.17", default-features = false, features = ["std"] }
rand = "0.8" rand = "0.8"
rcgen = "0.11" rcgen = "0.12"
rustls-pemfile = "1" rustls-pemfile = "2"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
static_assertions = "1" static_assertions = "1"
tls-openssl = { package = "openssl", version = "0.10.55" } tls-openssl = { package = "openssl", version = "0.10.55" }
tls-rustls = { package = "rustls", version = "0.21" } tls-rustls = { package = "rustls", version = "0.22" }
tokio = { version = "1.24.2", features = ["rt-multi-thread", "macros"] } tokio = { version = "1.24.2", features = ["rt-multi-thread", "macros"] }
zstd = "0.13" zstd = "0.13"

View File

@ -1,6 +1,6 @@
#[cfg(feature = "openssl")] #[cfg(feature = "openssl")]
extern crate tls_openssl as openssl; extern crate tls_openssl as openssl;
#[cfg(feature = "rustls-0_21")] #[cfg(feature = "rustls-0_22")]
extern crate tls_rustls as rustls; extern crate tls_rustls as rustls;
use std::{ use std::{
@ -708,7 +708,7 @@ async fn test_brotli_encoding_large_openssl() {
mod plus_rustls { mod plus_rustls {
use std::io::BufReader; use std::io::BufReader;
use rustls::{Certificate, PrivateKey, ServerConfig as RustlsServerConfig}; use rustls::{pki_types::PrivateKeyDer, ServerConfig as RustlsServerConfig};
use rustls_pemfile::{certs, pkcs8_private_keys}; use rustls_pemfile::{certs, pkcs8_private_keys};
use super::*; use super::*;
@ -721,17 +721,14 @@ mod plus_rustls {
let cert_file = &mut BufReader::new(cert_file.as_bytes()); let cert_file = &mut BufReader::new(cert_file.as_bytes());
let key_file = &mut BufReader::new(key_file.as_bytes()); let key_file = &mut BufReader::new(key_file.as_bytes());
let cert_chain = certs(cert_file) let cert_chain = certs(cert_file).collect::<Result<Vec<_>, _>>().unwrap();
.unwrap() let mut keys = pkcs8_private_keys(key_file)
.into_iter() .collect::<Result<Vec<_>, _>>()
.map(Certificate) .unwrap();
.collect();
let mut keys = pkcs8_private_keys(key_file).unwrap();
RustlsServerConfig::builder() RustlsServerConfig::builder()
.with_safe_defaults()
.with_no_client_auth() .with_no_client_auth()
.with_single_cert(cert_chain, PrivateKey(keys.remove(0))) .with_single_cert(cert_chain, PrivateKeyDer::Pkcs8(keys.remove(0)))
.unwrap() .unwrap()
} }
@ -743,7 +740,7 @@ mod plus_rustls {
.map(char::from) .map(char::from)
.collect::<String>(); .collect::<String>();
let srv = actix_test::start_with(actix_test::config().rustls_0_21(tls_config()), || { let srv = actix_test::start_with(actix_test::config().rustls_0_22(tls_config()), || {
App::new().service(web::resource("/").route(web::to(|bytes: Bytes| async { App::new().service(web::resource("/").route(web::to(|bytes: Bytes| async {
// echo decompressed request body back in response // echo decompressed request body back in response
HttpResponse::Ok() HttpResponse::Ok()