Skip to content

Commit eab0da1

Browse files
committed
fix: pin rustls-native-certs to <0.8.3
Version 0.8.3+ pulls in [email protected] which probes multiple certificate directories and parses individual cert files instead of loading a single bundle, adding unnecessary I/O overhead in latency-sensitive environments.
1 parent 87b12b6 commit eab0da1

11 files changed

Lines changed: 69 additions & 1 deletion

File tree

libdd-common/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ regex = "1.5"
4141
# Use rustls-no-provider instead of rustls to avoid reqwest forcing aws-lc-rs as the crypto
4242
# backend. We install the ring provider explicitly in connector/mod.rs instead.
4343
reqwest = { version = "0.13.2", features = ["rustls-no-provider", "hickory-dns"], default-features = false, optional = true }
44-
rustls-native-certs = { version = "0.8.1", optional = true }
44+
# Pinned to <0.8.3: version 0.8.3+ pulls in [email protected] which probes multiple
45+
# certificate directories and parses individual cert files instead of loading a single
46+
# bundle, adding unnecessary I/O overhead in latency-sensitive environments.
47+
rustls-native-certs = { version = ">=0.8.1, <0.8.3", optional = true }
4548
thiserror = "1.0"
4649
tokio = { version = "1.23", features = ["rt", "macros", "net", "io-util", "fs"] }
4750
tokio-rustls = { version = "0.26", default-features = false, optional = true }

libdd-http-client/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ http-body-util = { version = "0.1", optional = true }
3636

3737
[dev-dependencies]
3838
httpmock = "0.8.0-alpha.1"
39+
rustls = { version = "0.23", default-features = false, features = ["ring"] }
3940
tokio = { version = "1.23", features = ["rt", "macros", "io-util", "net"] }
4041
tempfile = "3"

libdd-http-client/src/client.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,13 @@ impl HttpClient {
104104
mod tests {
105105
use super::*;
106106

107+
fn ensure_crypto_provider() {
108+
let _ = rustls::crypto::ring::default_provider().install_default();
109+
}
110+
107111
#[test]
108112
fn new_creates_client() {
113+
ensure_crypto_provider();
109114
let client = HttpClient::new("http://localhost:8126".to_owned(), Duration::from_secs(3));
110115
assert!(client.is_ok());
111116
let client = client.unwrap();
@@ -115,6 +120,7 @@ mod tests {
115120

116121
#[test]
117122
fn builder_creates_client() {
123+
ensure_crypto_provider();
118124
let client = HttpClient::builder()
119125
.base_url("http://localhost:8126".to_owned())
120126
.timeout(Duration::from_secs(5))
@@ -127,6 +133,7 @@ mod tests {
127133
#[cfg_attr(miri, ignore)]
128134
#[tokio::test]
129135
async fn send_returns_error_when_no_server() {
136+
ensure_crypto_provider();
130137
let client =
131138
HttpClient::new("http://localhost".to_owned(), Duration::from_secs(1)).unwrap();
132139
let req = crate::HttpRequest::new(

libdd-http-client/src/config.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ impl HttpClientBuilder {
161161
mod tests {
162162
use super::*;
163163

164+
fn ensure_crypto_provider() {
165+
let _ = rustls::crypto::ring::default_provider().install_default();
166+
}
167+
164168
#[test]
165169
fn config_getters() {
166170
let config =
@@ -196,6 +200,7 @@ mod tests {
196200

197201
#[test]
198202
fn builder_success() {
203+
ensure_crypto_provider();
199204
let client = HttpClientBuilder::new()
200205
.base_url("http://localhost:8126".to_owned())
201206
.timeout(Duration::from_secs(3))
@@ -205,6 +210,7 @@ mod tests {
205210

206211
#[test]
207212
fn builder_treat_http_errors_defaults_true() {
213+
ensure_crypto_provider();
208214
let client = HttpClientBuilder::new()
209215
.base_url("http://localhost".to_owned())
210216
.timeout(Duration::from_secs(1))
@@ -215,6 +221,7 @@ mod tests {
215221

216222
#[test]
217223
fn builder_treat_http_errors_set_false() {
224+
ensure_crypto_provider();
218225
let client = HttpClientBuilder::new()
219226
.base_url("http://localhost".to_owned())
220227
.timeout(Duration::from_secs(1))

libdd-http-client/tests/connection_pool.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ use httpmock::prelude::*;
55
use libdd_http_client::{HttpClient, HttpMethod, HttpRequest};
66
use std::time::Duration;
77

8+
fn ensure_crypto_provider() {
9+
let _ = rustls::crypto::ring::default_provider().install_default();
10+
}
11+
812
#[cfg_attr(miri, ignore)]
913
#[tokio::test]
1014
async fn test_multiple_requests_reuse_client() {
15+
ensure_crypto_provider();
1116
let server = MockServer::start_async().await;
1217

1318
let mock = server
@@ -38,6 +43,7 @@ async fn test_multiple_requests_reuse_client() {
3843
#[cfg_attr(miri, ignore)]
3944
#[tokio::test]
4045
async fn test_concurrent_requests_succeed() {
46+
ensure_crypto_provider();
4147
let server = MockServer::start_async().await;
4248

4349
let mock = server

libdd-http-client/tests/http_round_trip.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ use httpmock::prelude::*;
55
use libdd_http_client::{HttpClient, HttpClientError, HttpMethod, HttpRequest};
66
use std::time::Duration;
77

8+
fn ensure_crypto_provider() {
9+
let _ = rustls::crypto::ring::default_provider().install_default();
10+
}
11+
812
#[cfg_attr(miri, ignore)]
913
#[tokio::test]
1014
async fn test_post_round_trip() {
15+
ensure_crypto_provider();
1116
let server = MockServer::start_async().await;
1217

1318
let mock = server
@@ -34,6 +39,7 @@ async fn test_post_round_trip() {
3439
#[cfg_attr(miri, ignore)]
3540
#[tokio::test]
3641
async fn test_get_round_trip() {
42+
ensure_crypto_provider();
3743
let server = MockServer::start_async().await;
3844

3945
let mock = server
@@ -59,6 +65,7 @@ async fn test_get_round_trip() {
5965
#[cfg_attr(miri, ignore)]
6066
#[tokio::test]
6167
async fn test_response_headers_returned() {
68+
ensure_crypto_provider();
6269
let server = MockServer::start_async().await;
6370

6471
let mock = server
@@ -89,6 +96,7 @@ async fn test_response_headers_returned() {
8996
#[cfg_attr(miri, ignore)]
9097
#[tokio::test]
9198
async fn test_4xx_returns_request_failed() {
99+
ensure_crypto_provider();
92100
let server = MockServer::start_async().await;
93101

94102
server
@@ -115,6 +123,7 @@ async fn test_4xx_returns_request_failed() {
115123
#[cfg_attr(miri, ignore)]
116124
#[tokio::test]
117125
async fn test_4xx_returns_ok_when_errors_disabled() {
126+
ensure_crypto_provider();
118127
let server = MockServer::start_async().await;
119128

120129
server
@@ -141,6 +150,7 @@ async fn test_4xx_returns_ok_when_errors_disabled() {
141150
#[cfg_attr(miri, ignore)]
142151
#[tokio::test]
143152
async fn test_5xx_returns_request_failed() {
153+
ensure_crypto_provider();
144154
let server = MockServer::start_async().await;
145155

146156
server

libdd-http-client/tests/multipart_test.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ use httpmock::prelude::*;
55
use libdd_http_client::{HttpClient, HttpMethod, HttpRequest, MultipartPart};
66
use std::time::Duration;
77

8+
fn ensure_crypto_provider() {
9+
let _ = rustls::crypto::ring::default_provider().install_default();
10+
}
11+
812
#[cfg_attr(miri, ignore)]
913
#[tokio::test]
1014
async fn test_multipart_upload() {
15+
ensure_crypto_provider();
1116
let server = MockServer::start_async().await;
1217

1318
let mock = server
@@ -39,6 +44,7 @@ async fn test_multipart_upload() {
3944
#[cfg_attr(miri, ignore)]
4045
#[tokio::test]
4146
async fn test_multipart_sets_content_type() {
47+
ensure_crypto_provider();
4248
let server = MockServer::start_async().await;
4349

4450
let mock = server

libdd-http-client/tests/retry_test.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ use httpmock::prelude::*;
55
use libdd_http_client::{HttpClient, HttpClientError, HttpMethod, HttpRequest, RetryConfig};
66
use std::time::Duration;
77

8+
fn ensure_crypto_provider() {
9+
let _ = rustls::crypto::ring::default_provider().install_default();
10+
}
11+
812
#[cfg_attr(miri, ignore)]
913
#[tokio::test]
1014
async fn test_retries_on_503() {
15+
ensure_crypto_provider();
1116
let server = MockServer::start_async().await;
1217

1318
let mock = server
@@ -43,6 +48,7 @@ async fn test_retries_on_503() {
4348
#[cfg_attr(miri, ignore)]
4449
#[tokio::test]
4550
async fn test_retries_on_404() {
51+
ensure_crypto_provider();
4652
let server = MockServer::start_async().await;
4753

4854
let mock = server
@@ -78,6 +84,7 @@ async fn test_retries_on_404() {
7884
#[cfg_attr(miri, ignore)]
7985
#[tokio::test]
8086
async fn test_no_retry_when_not_configured() {
87+
ensure_crypto_provider();
8188
let server = MockServer::start_async().await;
8289

8390
let mock = server
@@ -101,6 +108,7 @@ async fn test_no_retry_when_not_configured() {
101108
#[cfg_attr(miri, ignore)]
102109
#[tokio::test]
103110
async fn test_succeeds_after_transient_failure() {
111+
ensure_crypto_provider();
104112
let server = MockServer::start_async().await;
105113

106114
// First two calls return 503, third returns 200
@@ -139,6 +147,7 @@ async fn test_succeeds_after_transient_failure() {
139147
#[cfg_attr(miri, ignore)]
140148
#[tokio::test]
141149
async fn test_retries_on_connection_error() {
150+
ensure_crypto_provider();
142151
// Port 1 — nothing listening
143152
let client = HttpClient::builder()
144153
.base_url("http://127.0.0.1:1".to_owned())
@@ -161,6 +170,7 @@ async fn test_retries_on_connection_error() {
161170
#[cfg_attr(miri, ignore)]
162171
#[tokio::test]
163172
async fn test_backoff_increases() {
173+
ensure_crypto_provider();
164174
let server = MockServer::start_async().await;
165175

166176
server

libdd-http-client/tests/timeout_test.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ use httpmock::prelude::*;
55
use libdd_http_client::{HttpClient, HttpClientError, HttpMethod, HttpRequest};
66
use std::time::Duration;
77

8+
fn ensure_crypto_provider() {
9+
let _ = rustls::crypto::ring::default_provider().install_default();
10+
}
11+
812
#[cfg_attr(miri, ignore)]
913
#[tokio::test]
1014
async fn test_request_times_out() {
15+
ensure_crypto_provider();
1116
let server = MockServer::start_async().await;
1217

1318
server
@@ -31,6 +36,7 @@ async fn test_request_times_out() {
3136
#[cfg_attr(miri, ignore)]
3237
#[tokio::test]
3338
async fn test_per_request_timeout_overrides_client() {
39+
ensure_crypto_provider();
3440
let server = MockServer::start_async().await;
3541

3642
server
@@ -57,6 +63,7 @@ async fn test_per_request_timeout_overrides_client() {
5763
#[cfg_attr(miri, ignore)]
5864
#[tokio::test]
5965
async fn test_connection_refused() {
66+
ensure_crypto_provider();
6067
// Use port 1 which is very unlikely to have a listener.
6168
let client = HttpClient::new("http://127.0.0.1:1".to_owned(), Duration::from_secs(1)).unwrap();
6269

libdd-http-client/tests/uds_round_trip.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@ use std::time::Duration;
1010
use tokio::io::{AsyncReadExt, AsyncWriteExt};
1111
use tokio::net::UnixListener;
1212

13+
fn ensure_crypto_provider() {
14+
let _ = rustls::crypto::ring::default_provider().install_default();
15+
}
16+
1317
#[cfg_attr(miri, ignore)]
1418
#[tokio::test]
1519
async fn test_uds_round_trip() {
20+
ensure_crypto_provider();
1621
let dir = tempfile::tempdir().unwrap();
1722
let socket_path = dir.path().join("test.sock");
1823

0 commit comments

Comments
 (0)