Ray's Knowledge Base
Unlock

ureq/rustls downloads fail behind a TLS-intercepting proxy with UnknownIssuer

PitfallVerified 30 Sep 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

A Rust tool that downloads with ureq fails with io: invalid peer certificate: UnknownIssuer. One possible cause is a corporate TLS proxy whose CA is absent from the configured roots.

Cause#

ureq's default rustls configuration uses webpki roots. A corporate CA present only in the OS trust store is not included. Enabling ureq's platform-verifier feature makes another verifier available but does not select it.

Fix#

Enable the feature and create a ureq::Agent whose TLS config uses RootCerts::PlatformVerifier. Send requests through that Agent rather than ureq::get.

ureq = { version = "3", default-features = false, features = ["rustls", "platform-verifier"] }
use ureq::Agent;

static AGENT: std::sync::OnceLock<Agent> = std::sync::OnceLock::new();

fn agent() -> &'static Agent {
    AGENT.get_or_init(|| {
        Agent::config_builder()
            .tls_config(
                ureq::tls::TlsConfig::builder()
                    .root_certs(ureq::tls::RootCerts::PlatformVerifier)
                    .build(),
            )
            .build()
            .into()
    })
}

The OS store must still trust the required CA. Confirm that on the failing machine; a successful download on a different machine does not prove it. Keep certificate verification enabled.

For reqwest, native-root features or an explicitly added root certificate are separate configuration choices. Do not assume SSL_CERT_FILE is read unless the TLS integration wires it in.

Evidence#

Inbox 7fee697e57 contains the user's rkb models fetch failure and a second failure after the feature-only change. The agent inspected ureq 3.4.2 and found TlsConfig::default() still selected RootCerts::WebPki. It then configured the Agent in crates/rkb-rerank/src/files.rs and asked the user to rebuild and retry. No successful download on the failing machine is present in the extract. The earlier lesson reported cargo test -p rkb-rerank --lib passed; that is not an end-to-end TLS check. The unaffected Mac resolved the URL, while the user also reported a browser "Entry not found" error; the extract does not establish that error's cause.

Also found by searching

  • io: invalid peer certificate: UnknownIssuer
  • my Rust CLI cannot download files on the corporate network but curl works fine
  • how do I make ureq use the operating system certificate store instead of webpki roots
  • rustls platform-verifier feature enabled but still UnknownIssuer behind Zscaler proxy
  • io: invalid peer certificate: UnknownIssuer ureq download behind corporate proxy
  • rust tool download fails on work network with certificate error but works on my home Mac, browser is fine
  • how do I make ureq 3 use the OS trust store root certificates instead of webpki roots?
  • rustls platform-verifier feature enabled but still UnknownIssuer, SSL_CERT_FILE ignored, MITM proxy CA