Skip to main content

par_term/
http.rs

1//! HTTP client helper with native-tls support.
2//!
3//! This module provides a configured HTTP agent that uses native-tls
4//! for TLS connections, which works better in VM environments where
5//! ring/rustls may have issues.
6
7use ureq::Agent;
8use ureq::tls::{RootCerts, TlsConfig, TlsProvider};
9
10/// Create a new HTTP agent configured with native-tls.
11///
12/// This explicitly configures native-tls as the TLS provider, which uses
13/// the system's TLS library (Schannel on Windows, OpenSSL on Linux,
14/// Security.framework on macOS).
15///
16/// We use PlatformVerifier to use the system's built-in root certificates.
17pub fn agent() -> Agent {
18    let tls_config = TlsConfig::builder()
19        .provider(TlsProvider::NativeTls)
20        .root_certs(RootCerts::PlatformVerifier)
21        .build();
22
23    Agent::config_builder()
24        .tls_config(tls_config)
25        .build()
26        .into()
27}