forked from mirrors/relay
Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
6ec9e61364 |
2 changed files with 14 additions and 0 deletions
|
@ -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"
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue