fix: make build_rustls_config async and update its usage in main_task
This commit is contained in:
+5
-2
@@ -64,14 +64,17 @@ impl reqwest::dns::Resolve for HickoryDnsResolver {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build_rustls_config() -> crate::Result<rustls::ClientConfig> {
|
||||
pub async fn build_rustls_config() -> crate::Result<rustls::ClientConfig> {
|
||||
let provider = Arc::new(rustls::crypto::aws_lc_rs::default_provider());
|
||||
|
||||
Ok(rustls::ClientConfig::builder_with_provider(Arc::clone(&provider))
|
||||
.with_protocol_versions(rustls::ALL_VERSIONS)?
|
||||
.dangerous()
|
||||
.with_custom_certificate_verifier(Arc::new(
|
||||
rustls_platform_verifier::Verifier::new(provider)?,
|
||||
tokio::task::spawn_blocking(move || {
|
||||
rustls_platform_verifier::Verifier::new(provider)
|
||||
})
|
||||
.await??,
|
||||
))
|
||||
.with_no_client_auth())
|
||||
}
|
||||
|
||||
+4
-2
@@ -171,8 +171,10 @@ async fn main_task(
|
||||
event::Event,
|
||||
>,
|
||||
) -> crate::Result<()> {
|
||||
let dns_resolver = http::HickoryDnsResolver::new().await?;
|
||||
let tls_backend = http::build_rustls_config()?;
|
||||
let (dns_resolver, tls_backend) = tokio::try_join!(
|
||||
async { http::HickoryDnsResolver::new().await.map_err(Into::into) },
|
||||
http::build_rustls_config(),
|
||||
)?;
|
||||
|
||||
let http_client = http::create_reqwest_client(
|
||||
&config,
|
||||
|
||||
Reference in New Issue
Block a user