From 670cbbd4834b3400ae69f2a8caac4d4fd7f6c758 Mon Sep 17 00:00:00 2001 From: monosans Date: Thu, 15 Jan 2026 20:03:05 +0300 Subject: [PATCH] fix: make build_rustls_config async and update its usage in main_task --- src/http.rs | 7 +++++-- src/main.rs | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/http.rs b/src/http.rs index 67fe084..7359518 100644 --- a/src/http.rs +++ b/src/http.rs @@ -64,14 +64,17 @@ impl reqwest::dns::Resolve for HickoryDnsResolver { } } -pub fn build_rustls_config() -> crate::Result { +pub async fn build_rustls_config() -> crate::Result { 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()) } diff --git a/src/main.rs b/src/main.rs index 2a293a9..cc6c226 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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,