From b2440ad66d719cd37b2fbe28937cfa29f6fdc41b Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Wed, 20 Oct 2021 17:56:46 +0100 Subject: [PATCH] remove mutex features --- .cargo/config.toml | 2 +- .github/workflows/ci.yml | 6 ++--- Cargo.toml | 4 ++-- actix-http/src/client/connector.rs | 37 +++++++++++++----------------- 4 files changed, 21 insertions(+), 28 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 4974377dd..6b53a5bfe 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -8,7 +8,7 @@ ci-full = "check --workspace --all-features --bins --tests --examples" ci-test = "test --workspace --all-features --lib --tests --no-fail-fast -- --nocapture" ci-doctest = "test --workspace --all-features --doc --no-fail-fast -- --nocapture" - ci-feature-powerset-check-no-tls="hack --workspace --feature-powerset --skip=__compress,rustls,openssl check" ci-feature-powerset-check-rustls="hack --workspace --feature-powerset --features=rustls --skip=__compress,openssl check" ci-feature-powerset-check-openssl="hack --workspace --feature-powerset --features=openssl --skip=__compress,rustls check" +ci-feature-powerset-check-both="hack --workspace --feature-powerset --features=rustls,openssl --skip=__compress check" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad6b944c2..baf4da24c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -115,10 +115,8 @@ jobs: - name: check feature combinations # if: github.ref == 'refs/heads/master' - run: | - cargo ci-feature-powerset-check-no-tls - cargo ci-feature-powerset-check-openssl - cargo ci-feature-powerset-check-rustls + uses: actions-rs/cargo@v1 + with: { command: ci-feature-powerset-check-both } coverage: name: coverage diff --git a/Cargo.toml b/Cargo.toml index 0b4c8dcf4..152282207 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,15 +68,15 @@ __compress = [] [dependencies] actix-codec = "0.4.0" actix-macros = "0.2.3" -actix-router = "0.5.0-beta.2" actix-rt = "2.2" actix-server = "2.0.0-beta.3" actix-service = "2.0.0" actix-utils = "3.0.0" actix-tls = { version = "3.0.0-beta.7", default-features = false, optional = true } -actix-web-codegen = "0.5.0-beta.5" actix-http = "3.0.0-beta.11" +actix-router = "0.5.0-beta.2" +actix-web-codegen = "0.5.0-beta.5" ahash = "0.7" bytes = "1" diff --git a/actix-http/src/client/connector.rs b/actix-http/src/client/connector.rs index eda98e55a..4314511a3 100644 --- a/actix-http/src/client/connector.rs +++ b/actix-http/src/client/connector.rs @@ -79,14 +79,24 @@ impl Connector<()> { SslConnector::None } - /// Provides an empty TLS connector when no TLS feature is enabled. - #[cfg(all(feature = "openssl", feature = "rustls"))] - fn build_ssl(_: Vec>) -> SslConnector { - compile_error!("openssl and rustls features are mutually exclusive"); - panic!("openssl and rustls features are mutually exclusive"); + /// Build TLS connector with rustls, based on supplied ALPN protocols + /// + /// Note that if both `openssl` and `rustls` features are enabled, rustls will be used. + #[cfg(feature = "rustls")] + fn build_ssl(protocols: Vec>) -> SslConnector { + use actix_tls::connect::tls::rustls::{webpki_roots_cert_store, ClientConfig}; + + let mut config = ClientConfig::builder() + .with_safe_defaults() + .with_root_certificates(webpki_roots_cert_store()) + .with_no_client_auth(); + + config.alpn_protocols = protocols; + + SslConnector::Rustls(std::sync::Arc::new(config)) } - // Build TLS connector with openssl, based on supplied alpn protocols + /// Build TLS connector with openssl, based on supplied ALPN protocols #[cfg(all(feature = "openssl", not(feature = "rustls")))] fn build_ssl(protocols: Vec>) -> SslConnector { use actix_tls::connect::tls::openssl::{ @@ -107,21 +117,6 @@ impl Connector<()> { SslConnector::Openssl(ssl.build()) } - - // Build TLS connector with rustls, based on supplied alpn protocols - #[cfg(all(feature = "rustls", not(feature = "openssl")))] - fn build_ssl(protocols: Vec>) -> SslConnector { - use actix_tls::connect::tls::rustls::{webpki_roots_cert_store, ClientConfig}; - - let mut config = ClientConfig::builder() - .with_safe_defaults() - .with_root_certificates(webpki_roots_cert_store()) - .with_no_client_auth(); - - config.alpn_protocols = protocols; - - SslConnector::Rustls(std::sync::Arc::new(config)) - } } impl Connector {