From c62eae8230b2638457cdb9cf8ed1c0d80f3100d4 Mon Sep 17 00:00:00 2001 From: "Helmut K. C. Tessarek" Date: Fri, 31 May 2024 23:36:28 -0400 Subject: [PATCH] refactor: use hyper-rustls --- metrics-exporter-prometheus/Cargo.toml | 4 ++-- metrics-exporter-prometheus/src/exporter/push_gateway.rs | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/metrics-exporter-prometheus/Cargo.toml b/metrics-exporter-prometheus/Cargo.toml index f1f4c700..ea77fe24 100644 --- a/metrics-exporter-prometheus/Cargo.toml +++ b/metrics-exporter-prometheus/Cargo.toml @@ -22,7 +22,7 @@ async-runtime = ["tokio", "hyper-util/tokio"] http-listener = ["async-runtime", "ipnet", "tracing", "_hyper-server"] push-gateway = ["async-runtime", "tracing", "_hyper-client"] _hyper-server = ["http-body-util", "hyper/server", "hyper-util/server-auto"] -_hyper-client = ["http-body-util", "hyper/client", "hyper-util/client", "hyper-util/http1", "hyper-util/client-legacy", "hyper-tls"] +_hyper-client = ["http-body-util", "hyper/client", "hyper-util/client", "hyper-util/http1", "hyper-util/client-legacy", "hyper-rustls"] [dependencies] metrics = { version = "^0.23", path = "../metrics" } @@ -39,7 +39,7 @@ http-body-util = { version = "0.1.0", optional = true } ipnet = { version = "2", optional = true } tokio = { version = "1", features = ["rt", "net", "time", "rt-multi-thread"], optional = true } tracing = { version = "0.1.26", optional = true } -hyper-tls = { version = "0.6.0", optional = true } +hyper-rustls = { version = "0.27.2", optional = true } [dev-dependencies] tracing = "0.1" diff --git a/metrics-exporter-prometheus/src/exporter/push_gateway.rs b/metrics-exporter-prometheus/src/exporter/push_gateway.rs index c1f67b4a..f11b416d 100644 --- a/metrics-exporter-prometheus/src/exporter/push_gateway.rs +++ b/metrics-exporter-prometheus/src/exporter/push_gateway.rs @@ -3,7 +3,6 @@ use std::time::Duration; use http_body_util::{BodyExt, Collected, Full}; use hyper::body::Bytes; use hyper::{header::HeaderValue, Method, Request, Uri}; -use hyper_tls::HttpsConnector; use hyper_util::{client::legacy::Client, rt::TokioExecutor}; use tracing::error; @@ -19,7 +18,12 @@ pub(super) fn new_push_gateway( handle: PrometheusHandle, ) -> ExporterFuture { Box::pin(async move { - let https = HttpsConnector::new(); + let https = hyper_rustls::HttpsConnectorBuilder::new() + .with_native_roots() + .expect("no native root CA certificates found") + .https_only() + .enable_http1() + .build(); let client: Client<_, Full> = Client::builder(TokioExecutor::new()) .pool_idle_timeout(Duration::from_secs(30)) .build(https);