Skip to content

Commit 654c3a1

Browse files
authored
metrics-exporter-prometheus: use hyper-rustls (#489)
1 parent 4c002c4 commit 654c3a1

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

metrics-exporter-prometheus/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async-runtime = ["tokio", "hyper-util/tokio"]
2222
http-listener = ["async-runtime", "ipnet", "tracing", "_hyper-server"]
2323
push-gateway = ["async-runtime", "tracing", "_hyper-client"]
2424
_hyper-server = ["http-body-util", "hyper/server", "hyper-util/server-auto"]
25-
_hyper-client = ["http-body-util", "hyper/client", "hyper-util/client", "hyper-util/http1", "hyper-util/client-legacy", "hyper-tls"]
25+
_hyper-client = ["http-body-util", "hyper/client", "hyper-util/client", "hyper-util/http1", "hyper-util/client-legacy", "hyper-rustls"]
2626

2727
[dependencies]
2828
metrics = { version = "^0.23", path = "../metrics" }
@@ -39,7 +39,7 @@ http-body-util = { version = "0.1.0", optional = true }
3939
ipnet = { version = "2", optional = true }
4040
tokio = { version = "1", features = ["rt", "net", "time", "rt-multi-thread"], optional = true }
4141
tracing = { version = "0.1.26", optional = true }
42-
hyper-tls = { version = "0.6.0", optional = true }
42+
hyper-rustls = { version = "0.27.2", optional = true }
4343

4444
[dev-dependencies]
4545
tracing = "0.1"

metrics-exporter-prometheus/src/exporter/push_gateway.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::time::Duration;
33
use http_body_util::{BodyExt, Collected, Full};
44
use hyper::body::Bytes;
55
use hyper::{header::HeaderValue, Method, Request, Uri};
6-
use hyper_tls::HttpsConnector;
76
use hyper_util::{client::legacy::Client, rt::TokioExecutor};
87
use tracing::error;
98

@@ -19,7 +18,12 @@ pub(super) fn new_push_gateway(
1918
handle: PrometheusHandle,
2019
) -> ExporterFuture {
2120
Box::pin(async move {
22-
let https = HttpsConnector::new();
21+
let https = hyper_rustls::HttpsConnectorBuilder::new()
22+
.with_native_roots()
23+
.expect("no native root CA certificates found")
24+
.https_or_http()
25+
.enable_http1()
26+
.build();
2327
let client: Client<_, Full<Bytes>> = Client::builder(TokioExecutor::new())
2428
.pool_idle_timeout(Duration::from_secs(30))
2529
.build(https);

0 commit comments

Comments
 (0)