Skip to content

Commit 2ad58f6

Browse files
committed
feat(download/rustls): use rustls-platform-verifier
1 parent 20a1c81 commit 2ad58f6

File tree

3 files changed

+135
-17
lines changed

3 files changed

+135
-17
lines changed

Cargo.lock

Lines changed: 111 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

download/Cargo.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,21 @@ default = ["reqwest-backend", "reqwest-rustls-tls", "reqwest-native-tls"]
99
curl-backend = ["curl"]
1010
reqwest-backend = ["reqwest", "env_proxy"]
1111
reqwest-native-tls = ["reqwest/native-tls", "dep:once_cell"]
12-
reqwest-rustls-tls = ["reqwest/rustls-tls-native-roots", "dep:once_cell"]
12+
reqwest-rustls-tls = [
13+
"reqwest/rustls-tls-manual-roots-no-provider",
14+
"dep:rustls",
15+
"dep:rustls-platform-verifier",
16+
"dep:once_cell",
17+
]
1318

1419
[dependencies]
1520
anyhow.workspace = true
1621
curl = { version = "0.4.44", optional = true }
1722
env_proxy = { version = "0.4.1", optional = true }
1823
once_cell = { workspace = true, optional = true }
1924
reqwest = { version = "0.12", default-features = false, features = ["blocking", "gzip", "socks", "stream"], optional = true }
25+
rustls = { version = "0.23", optional = true, default-features = false, features = ["logging", "ring", "tls12"] }
26+
rustls-platform-verifier = { version = "0.3", optional = true }
2027
thiserror.workspace = true
2128
tokio = { workspace = true, default-features = false, features = ["sync"] }
2229
tokio-stream.workspace = true

download/src/lib.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,16 +293,22 @@ pub mod reqwest_be {
293293
))]
294294
compile_error!("Must select a reqwest TLS backend");
295295

296-
use std::io;
297-
use std::time::Duration;
296+
use std::{io, time::Duration};
297+
298+
#[cfg(feature = "reqwest-rustls-tls")]
299+
use std::sync::Arc;
298300

299301
use anyhow::{anyhow, Context, Result};
300-
#[cfg(any(feature = "reqwest-rustls-tls", feature = "reqwest-native-tls"))]
301-
use once_cell::sync::Lazy;
302302
use reqwest::{header, Client, ClientBuilder, Proxy, Response};
303303
use tokio_stream::StreamExt;
304304
use url::Url;
305305

306+
#[cfg(any(feature = "reqwest-rustls-tls", feature = "reqwest-native-tls"))]
307+
use once_cell::sync::Lazy;
308+
309+
#[cfg(feature = "reqwest-rustls-tls")]
310+
use rustls::crypto::ring;
311+
306312
use super::{DownloadError, Event, TlsBackend};
307313

308314
pub async fn download(
@@ -353,7 +359,12 @@ pub mod reqwest_be {
353359
static CLIENT_RUSTLS_TLS: Lazy<Client> = Lazy::new(|| {
354360
let catcher = || {
355361
client_generic()
356-
.use_rustls_tls()
362+
.use_preconfigured_tls(
363+
rustls_platform_verifier::tls_config_with_provider(Arc::new(
364+
ring::default_provider(),
365+
))
366+
.expect("failed to initialize pre-configured rustls backend"),
367+
)
357368
.user_agent(super::REQWEST_RUSTLS_TLS_USER_AGENT)
358369
.build()
359370
};

0 commit comments

Comments
 (0)