Platform-conditional TLS backend selection for reqwest HTTP clients. A single tiny utility that centralises the #[cfg(target_os = "windows")] guard so every HTTP-client construction site picks the right TLS backend in one line, and future policy changes live in exactly one place.
- Provide one canonical
reqwest::ClientBuilderfactory pre-configured with the platform-appropriate TLS backend. - Encode the cross-platform TLS policy:
- Windows →
native-tls(schannel). Honors the Windows certificate store, including corporate / AV / TLS-inspecting-proxy CAs.rustls+ webpki-roots only knows Mozilla CAs and fails such environments withUnknownIssuer. - macOS / Linux →
rustls+ webpki-roots. Avoids the OpenSSL runtime dependency on Linux; historically more reliable on macOS staging TLS handshakes thannative-tls.
- Windows →
| File | Role |
|---|---|
src/openhuman/util/tls/mod.rs |
Entire module. Module docstring (policy) + the single tls_client_builder() function. No mod/pub mod decls; no submodules. |
tls_client_builder() -> reqwest::ClientBuilder— returns areqwest::Client::builder()with.use_native_tls()on Windows and.use_rustls_tls()elsewhere, selected at compile time viacfg. Intended as the starting point for any client reaching external HTTPS endpoints; callers chain.timeout(...),.http1_only(), proxy config, etc. and then.build().
None. Not RPC-facing — no schemas.rs, no controllers.
None.
None.
None — stateless, pure factory.
- External crate
reqwest(and itsnative-tls/rustlsfeature backends) only. Nouse crate::openhuman::*oruse crate::core::*imports — this is a leaf utility module with zero internal dependencies.
Every HTTP-client construction site that talks to external HTTPS endpoints, including:
src/openhuman/config/schema/proxy.rs— proxy-aware client builders (primary + fallback).src/openhuman/integrations/client.rsand integration tools (tools/searxng.rs,tools/brave.rs,tools/querit.rs,tools/seltz.rs).src/openhuman/inference/provider/compatible.rs— OpenAI-compatible inference provider clients.src/openhuman/integrations/composio/client.rs,src/openhuman/desktop/app_state/ops.rs.src/api/rest.rs(REST API client).
Registered in the domain tree via pub mod tls; in src/openhuman/mod.rs.
- Backend choice is compile-time (
cfg(target_os = ...)), not runtime — you cannot switch backends at runtime without recompiling for the target. - Always start from
tls_client_builder()rather thanreqwest::Client::builder()directly, otherwise Windows corporate-CA environments will fail withUnknownIssuer. - The doctest in the docstring is
rust,ignore.