From 13f05b8bb0123e36d31dea082dbee8331a51772c Mon Sep 17 00:00:00 2001 From: Kushagra Udai Date: Sat, 20 Jul 2024 12:39:48 -0700 Subject: [PATCH] Fix non-additive features --- .github/workflows/main.yml | 2 +- CHANGELOG.md | 1 + Cargo.toml | 9 ++------- src/lib.rs | 15 +-------------- 4 files changed, 5 insertions(+), 22 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c0af32c..5d1766f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,7 +24,7 @@ jobs: test: strategy: matrix: - features: ["", "--no-default-features --features rustls-native"] + features: [""] runs-on: "ubuntu-latest" container: rust:1.79 services: diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d40fb4..6dfbdfd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - `hyper-rustls` updated to version `0.27` from `0.24`. - `get_service_nodes` now supports tags thanks to @gautamg795 - `read_key` now also returns the index thanks to @badalex +- Removed `rustls-native-roots` feature and now defaults to `rustls-webpki-roots`. This addresses the bug that features were not additive. ## 0.6.0 - 2024-04-01 diff --git a/Cargo.toml b/Cargo.toml index b315332..bc71f88 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,10 +10,8 @@ license-file = "LICENSE" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] -default = ["rustls-webpki"] +default = [] metrics = ["prometheus", "lazy_static"] -rustls-native = ["hyper-rustls/rustls-native-certs"] -rustls-webpki = ["hyper-rustls/webpki-roots"] trace = ["dep:opentelemetry"] # keep this list sorted! @@ -22,7 +20,7 @@ base64 = "0.22" http = "1" http-body-util = "0.1" hyper = { version = "1", features = ["full"] } -hyper-rustls = { version = "0.27", features = ["ring"] } +hyper-rustls = { version = "0.27", features = ["webpki-roots"] } hyper-util = { version = "0.1", features = ["client", "client-legacy", "tokio", "http2"] } lazy_static = { version = "1", optional = true } opentelemetry = { version = "0.24", optional = true } @@ -34,6 +32,3 @@ slog-scope = "4" smart-default = "0.7" tokio = { version = "1", features = ["full"] } ureq = { version = "2", features = ["json"] } - -[dev-dependencies] -rustls = { version = "0.23", features = ["ring"] } diff --git a/src/lib.rs b/src/lib.rs index 229d25e..7577f8a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -39,7 +39,6 @@ use http_body_util::{Empty, Full}; use hyper::body::Bytes; use hyper::{body::Buf, Method}; use hyper_util::client::legacy::{connect::HttpConnector, Builder, Client}; -#[cfg(any(feature = "rustls-native", feature = "rustls-webpki"))] #[cfg(feature = "metrics")] use lazy_static::lazy_static; use quick_error::quick_error; @@ -256,16 +255,8 @@ pub struct Consul { } fn https_connector() -> Result> { - #[cfg(feature = "rustls-webpki")] - return Ok(hyper_rustls::HttpsConnectorBuilder::new() - .with_webpki_roots() - .https_or_http() - .enable_http1() - .build()); - #[allow(unreachable_code)] - // Clippy doesn't realize if the feature is disabled, this code would execute. Ok(hyper_rustls::HttpsConnectorBuilder::new() - .with_native_roots()? + .with_webpki_roots() .https_or_http() .enable_http1() .build()) @@ -949,7 +940,6 @@ fn record_duration_metric_if_enabled(_method: &Method, _function: &str, _duratio mod tests { use std::time::Duration; - use rustls::crypto::ring::default_provider; use tokio::time::sleep; use super::*; @@ -1335,9 +1325,6 @@ mod tests { } fn get_client() -> Consul { - default_provider() - .install_default() - .expect("Failed to install rustls crypto provider"); let conf: Config = Config::from_env(); Consul::new(conf).unwrap() }