Skip to content

Commit

Permalink
Fix non-additive features
Browse files Browse the repository at this point in the history
  • Loading branch information
kushudai committed Jul 20, 2024
1 parent 881cb1b commit 13f05b8
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 2 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand All @@ -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 }
Expand All @@ -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"] }
15 changes: 1 addition & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -256,16 +255,8 @@ pub struct Consul {
}

fn https_connector() -> Result<hyper_rustls::HttpsConnector<HttpConnector>> {
#[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())
Expand Down Expand Up @@ -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::*;
Expand Down Expand Up @@ -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()
}
Expand Down

0 comments on commit 13f05b8

Please sign in to comment.