From 6ec9e613643f84d7215be8fcb5a84a9ce5671e57 Mon Sep 17 00:00:00 2001 From: Rafael Caricio Date: Thu, 10 Aug 2023 22:16:18 +0200 Subject: [PATCH] Relay local changes while testing --- Cargo.toml | 1 + src/requests.rs | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 306f61f..9e7e6b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,6 +59,7 @@ ring = "0.16.20" rsa = { version = "0.9" } rsa-magic-public-key = "0.8.0" rustls = "0.20.7" +rustls-native-certs = "0.6.3" rustls-pemfile = "1.0.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/src/requests.rs b/src/requests.rs index 8b77028..e871d03 100644 --- a/src/requests.rs +++ b/src/requests.rs @@ -172,11 +172,24 @@ pub(crate) fn build_client(user_agent: &str, pool_size: usize, timeout_seconds: .get_or_init(|| { let connector = Connector::new().limit(pool_size); + let mut roots = rustls::RootCertStore::empty(); + for cert in rustls_native_certs::load_native_certs().expect("could not load platform certs") { + roots + .add(&rustls::Certificate(cert.0)) + .unwrap(); + } + + let config = rustls::ClientConfig::builder() + .with_safe_defaults() + .with_root_certificates(roots) + .with_no_client_auth(); + Client::builder() .connector(connector) .wrap(Tracing) .add_default_header(("User-Agent", user_agent.to_string())) .timeout(Duration::from_secs(timeout_seconds)) + .connector(awc::Connector::new().rustls(Arc::new(config))) .finish() }) .clone()