SSL certificate verify failed through a proxy: find the hop

SSL certificate verify failed behind a proxy? Find out which hop rejected the certificate, read the error text, and trust the right root without verify=False.

Open server with certificate modules, SSL certificate verify failed behind a proxy
Quick summary · TL;DR
  1. Read the words after the last colon first. self-signed certificate in certificate chain through a proxy usually means something re-signed the traffic, often a company gateway or antivirus, and your client doesn't trust its root.
  2. Look for a ProxyError wrapper around the SSL error. SSLCertVerificationError sitting inside ProxyError means requests failed on the proxy's own certificate. Check for https:// in your proxy URL before anything else.
  3. SSL_CERT_FILE won't help requests. It reads REQUESTS_CA_BUNDLE, and in a test on 2026-11-05 that variable even overrode session.verify, which is why this one eats so much time.
  4. A break right after moving to Python 3.13 points at strict checking. It now refuses some roots that curl and Node still accept, with reasons like CA cert does not include key usage extension. Adding the root again does nothing, and what you need is a reissued one.

An SSL certificate verify failed proxy error means your client rejected a certificate during the TLS handshake, and a plain CONNECT proxy, which only relays bytes, rarely causes this alone. The usual culprit is something on the path re-signing traffic with a root you don’t trust. The other one is an https:// proxy URL, which makes the client check the proxy’s own certificate.

The words after the last colon are the part to read:

[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1082)

Ignore the _ssl.c number when you search for it, because it changes between Python builds. It was 1010, 1032 and 1082 on three versions tested for this guide, with the same failure each time.

SSL certificate verify failed: which hop

Three different setups produce an SSL certificate verify failed proxy error, and each one has its own fix.

  • A normal tunnel. The proxy URL starts with http://, your client sends CONNECT example.com:443, and the proxy relays bytes once it has replied 200 (RFC 9110, section 9.3.6, June 2022). The certificate your client sees is the site’s own.
  • TLS inspection. The proxy accepts the CONNECT and then answers the handshake itself, using a certificate it minted on the spot. Corporate gateways, antivirus web shields and debugging tools like mitmproxy all work this way. Some scraping unblocker products may too, since their docs ask you to load the vendor’s certificate, though that comes from documentation and wasn’t tested here.
  • TLS to the proxy. The proxy URL starts with https://, so your client verifies the proxy’s certificate before it ever asks for the site.

In Python, requests already tells you which hop failed, and it’s easy to miss because the part that matters sits in the middle of a long line:

The exception readsThe hop that failed
SSLError(SSLCertVerificationError(...))The destination, or whatever answered in its place
ProxyError('Unable to connect to proxy', SSLError(SSLCertVerificationError(...)))The proxy’s own certificate
ProxyError('Unable to connect to proxy. Your proxy appears to only use HTTP and not HTTPS...The URL scheme, with no certificate involved

That split is urllib3 2.x behavior. Its 1.26 source turns a certificate failure into a plain SSLError whichever hop failed, so on 1.26 the first row can’t clear the proxy and you go by the scheme in your proxy URL. pip show urllib3 settles which one you have.

The proxy category plays no part in any of this. On proxymint, rotating residential proxies, static ISP, mobile and datacenter all include HTTP and SOCKS5, and over the HTTP side an HTTPS site runs through CONNECT. Whatever you use, the command in the next section shows who signed what you received. If you are still setting up the client, the Python requests proxy guide covers the proxies dict.

See who signed the certificate

This command does the handshake through the proxy and prints the chain your client was handed. It is worth running before you change any code. Put in the host that’s actually failing, since inspection rules can exempt some sites, and drop both credential flags if your proxy has no login.

export PROXY_PASS='your-password'
openssl s_client -proxy HOST:PORT -proxy_user USERNAME -proxy_pass env:PROXY_PASS \
  -connect example.com:443 -servername example.com -showcerts </dev/null 2>/dev/null \
  | grep -E "^ *[0-9]+ s:|^ +i:|Verify return code"

Against a local test proxy doing inspection and asking for a login, it printed this:

 0 s:CN=example.test
   i:CN=Test Inspection CA
 1 s:CN=Test Inspection CA
   i:CN=Test Inspection CA
Verify return code: 19 (self-signed certificate in certificate chain)

Two other results are easy to misread, because 2>/dev/null hides the reason.

  • Verify return code: 0 (ok) with no s: lines. OpenSSL 3.6.3 printed this after getting a 407 for a wrong password, so that line alone proves nothing and no certificate was checked.
  • Empty output. The flags were refused. The two credential flags appear in the OpenSSL 3.0 docs and not in the 1.1.1 ones, and the built-in openssl on macOS, LibreSSL 3.3.6, stops with unknown option -proxy_user. Use Homebrew’s OpenSSL there, or read the issuer: line from curl -vkI --proxy http://USERNAME:PASSWORD@HOST:PORT https://example.com/ 2>&1, where -k only serves this one header check.

-proxy speaks HTTP CONNECT, so point it at the proxy’s HTTP port and not at SOCKS5.

Look at the i: lines, since they name the issuer. Then run it once more without -proxy and its two credential flags, from outside that proxy, a phone hotspot for example, and compare. A browser loading the site proves nothing on a managed laptop, because IT’s root may already be in it.

  • Same public CA both ways. Nothing is re-signing your traffic, so the problem is your client’s bundle, your clock or the URL. On macOS, a python.org install has its own step here, since Install Certificates.command is what gives it root certificates.
  • A company, security product or unblocker vendor name through the proxy. That’s inspection, and the next sections fix it.
  • A name you can’t place, on a network you don’t run. Stop there and send nothing sensitive. A free public proxy that swaps certificates can read your traffic, and installing its root would make that invisible.

Match the error text

Every string below was printed by a real run on 2026-11-05, on macOS 26.6.2 with a throwaway proxy and test certificates bound to 127.0.0.1, so nothing left the machine. Versions were Python 3.12.13, 3.13.14 and 3.14.6, requests 2.34.2, urllib3 2.8.0, certifi 2026.10.23, curl 8.7.1 (LibreSSL), Node 24.14.1, git 2.50.1, pip 26.3 and OpenSSL 3.6.3. The bare self-signed certificate row came from a separate in-memory handshake on the same Pythons and Node, no proxy involved.

Reason textNode codeWhat it usually meansFix
self-signed certificate in certificate chainSELF_SIGNED_CERT_IN_CHAINInspection, and the proxy sent its root alongTrust that root
self-signed certificateDEPTH_ZERO_SELF_SIGNED_CERTThe certificate signed itself and came alone, typically an https:// proxy or an internal serverFix the proxy URL, or trust that certificate once its owner confirms it
unable to get local issuer certificateUNABLE_TO_GET_ISSUER_CERT_LOCALLY, or UNABLE_TO_VERIFY_LEAF_SIGNATURE if only the site certificate was sentInspection without the root, or a server that left out its intermediateTrust the root, add the intermediate to the bundle
unable to get issuer certificateUNABLE_TO_GET_ISSUER_CERTYour bundle holds an intermediate but not its rootAdd the root
certificate has expiredCERT_HAS_EXPIREDExpired site certificate, or an old minted oneRenew it, or tell whoever runs the proxy
certificate is not yet validCERT_NOT_YET_VALIDYour machine’s clock is wrongFix the clock, and check fresh VMs and containers first
Hostname mismatch, certificate is not valid for 'other.test'.ERR_TLS_CERT_ALTNAME_INVALIDThe certificate names a different hostCheck the URL, then the proxy’s minting
CA cert does not include key usage extensionacceptedPython 3.13 or later, strict checkingSee the Python 3.13 section

Other builds and clients word some of these differently.

  • Python 3.12 on OpenSSL 3.6.3 printed certificate is not yet valid or the system clock is incorrect.
  • curl and git on LibreSSL printed “self signed” with no hyphen, and for the mismatch curl said no alternative certificate subject name matches target host name.
  • Node’s message for the site-certificate-only case reads unable to verify the first certificate.
  • pip on macOS printed “Test Inspection CA” certificate is not trusted.

Python’s urllib raises the same reason text wrapped as URLError, and curl puts it after curl: (60) SSL certificate problem:. When a CONNECT itself fails you get a tunnel error instead, with no certificate check at all, so a status code in the message means you’re on the wrong page.

Trust the inspecting root

Get the root from whoever runs the proxy, usually IT or the security tool’s admin console. You can read it out of the s_client output, but that gives you whatever the network chose to send, so compare its SHA-256 fingerprint with one from IT first:

openssl x509 -in company-root.pem -noout -fingerprint -sha256

Then build a combined bundle rather than pointing Python at the root alone. REQUESTS_CA_BUNDLE replaces certifi, so a root-only file breaks every host your proxy doesn’t intercept.

cat "$(python -m certifi)" company-root.pem > bundle.pem
export REQUESTS_CA_BUNDLE="$PWD/bundle.pem"

Look at the root file first, because this one fails silently. IT often hands out a binary DER .cer, and when one was appended to certifi’s bundle in the 2026-11-05 test, all three Pythons loaded the file with no error and the CA count didn’t move. So the root just wasn’t there. If the first line isn’t -----BEGIN CERTIFICATE-----, convert it before the cat:

openssl x509 -inform der -in company-root.cer -out company-root.pem

bundle.pem is a snapshot too, so rebuild it when you upgrade certifi.

Each client looks somewhere else, a common reason for “curl works, my script doesn’t”. Your browser and OS may trust a root pushed by IT, while requests uses certifi (docs checked 2026-11-05) and ignores the OS store. If the root is already in the OS store, truststore (Python 3.10 or later) makes requests read that store once your script calls truststore.inject_into_ssl(), which is usually the shortest route on a managed Windows laptop.

ClientWhere the root goes
requestsverify="bundle.pem" or REQUESTS_CA_BUNDLE
urllib and ssl defaultsSSL_CERT_FILE
httpxSSL_CERT_FILE, or verify=ssl.create_default_context(cafile="bundle.pem"). It ignores REQUESTS_CA_BUNDLE
curl--cacert bundle.pem
NodeNODE_EXTRA_CA_CERTS=root.pem before launch, or --use-system-ca (Node docs, checked 2026-11-05)
gitgit config http.sslCAInfo bundle.pem
pip--cert bundle.pem or PIP_CERT (pip docs, checked 2026-11-05)
Java (PKIX path building failed)keytool -importcert into the truststore your JVM reads (keytool docs, checked 2026-11-05)

truststore, the Java row and Node’s --use-system-ca come from docs and weren’t part of the test. Every other setting ran and passed, httpx 0.28.1 included. pip 24.2 and later also reads system certificates by default, so pip can succeed where requests fails on the same machine.

A container needs this too, since the root your host trusts isn’t in the image. On a Debian-based image the update-ca-certificates man page wants a PEM file ending in .crt, and this wasn’t run in the test:

COPY company-root.pem /usr/local/share/ca-certificates/company-root.crt
RUN update-ca-certificates
ENV REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt

The REQUESTS_CA_BUNDLE traps

Three behaviors from that same run, identical on Python 3.12, 3.13 and 3.14:

  • SSL_CERT_FILE does nothing for requests. It fixed urllib in the same process while requests kept failing, which sends people in circles.
  • REQUESTS_CA_BUNDLE beats session.verify. With the variable set, a session using s.verify = "right.pem" still failed, and s.verify = False was ignored too. A leftover CURL_CA_BUNDLE does the same job when REQUESTS_CA_BUNDLE is unset.
  • A path or False in verify= on the call beats the variable, though verify=True still picks it up. s.trust_env = False beats it too, and that one also stops requests reading proxy settings from the environment, so pass proxies explicitly.

The requests docs add one more: a prepared request sent with Session.send skips the environment, so REQUESTS_CA_BUNDLE never applies there.

Python 3.13 rejects roots curl accepts

If a working setup broke right after a Python upgrade, this is the likely reason. Python 3.13 added VERIFY_X509_STRICT and VERIFY_X509_PARTIAL_CHAIN to ssl.create_default_context(). urllib3 applies the same flags from 2.4.0, and on Python 3.13 version 2.3.0 didn’t set them, so bumping urllib3 can be what breaks requests. Roots that were generated by hand or by an older appliance can fail the stricter check even when you trust them correctly. The local test gave each client a bundle that already held the right root:

The real fix is a reissue from whoever runs the proxy, which means a new root for the key usage and basic constraints rows, and minted site certificates that carry the identifier for the other one. Until then you can relax that one flag for one session, which the Python docs allow while advising against it:

import ssl
import requests
from requests.adapters import HTTPAdapter
from urllib3.util.ssl_ import create_urllib3_context

class RelaxedRoot(HTTPAdapter):
    def proxy_manager_for(self, *args, **kwargs):
        ctx = create_urllib3_context()
        ctx.load_verify_locations("bundle.pem")
        ctx.verify_flags &= ~ssl.VERIFY_X509_STRICT
        kwargs["ssl_context"] = ctx
        return super().proxy_manager_for(*args, **kwargs)

session = requests.Session()
session.mount("https://", RelaxedRoot())

In the test this passed on Python 3.13.14 and 3.14.6 and still refused a certificate from a root outside the bundle, which is the difference between this and verify=False. It only takes effect on proxied requests, because proxy_manager_for is the only method it overrides.

The partial-chain flag moved the other way. A bundle holding only the intermediate failed on Python 3.12 with unable to get issuer certificate, and passed on 3.13 and 3.14. It also passed on curl and failed on Node, so older advice that an intermediate alone is never enough now depends on the client.

An https:// proxy URL adds TLS

Scraping code often writes https:// in the proxy URL because the target is HTTPS. The https key picks which requests use the proxy, while the scheme in the value says how your client reaches it, and HTTPS sites go through an http:// proxy URL just fine:

proxies = {
    "http": "http://USERNAME:PASSWORD@HOST:PORT",
    "https": "http://USERNAME:PASSWORD@HOST:PORT",
}

HTTPS_PROXY works the same way, so check that variable as well. If the port speaks plain HTTP, changing the scheme to http:// makes the error go away. Before that fix, what you see depends on the port.

  • Plain HTTP on that port makes urllib3 print the “appears to only use HTTP” message from the first table, and the curl build tested here printed curl: (35) with a TLS alert.
  • A port that stays silent gave a read timeout in the same ProxyError wrapper.

A proxy that really does take TLS, such as some company gateways, adds a second certificate to check. The same test showed two things about that setup:

  • requests has no separate proxy setting on its public API. The file given to verify was used for both hops, so it needs both roots. That’s despite the docs line that says the option “only applies to host certs”. curl keeps them apart, with --proxy-cacert for the proxy and --cacert for the site.
  • verify=False turned off the proxy check as well, on urllib3 2.7.0 and 2.8.0 alike.

If you run this setup, read the recent urllib3 advisory. GHSA-8988-9cw3-xx77, published 2026-09-15 and rated high, covers urllib3 1.26.0 through 2.7.0, where target TLS settings could override or switch off the proxy’s. Version 2.8.0 fixes it, and proxy CA settings now belong in proxy_ssl_context. The changelog warns that configurations relying on the old behavior may need changes, though a verify= file on requests behaved the same on 2.7.0 and 2.8.0 in the test. Plain http:// proxies aren’t affected, as the advisory says.

Why verify=False is wrong

The error goes away and whatever caused it stays on the path.

An expired root, a new inspection box and an attacker all look identical once the check is off. The one fair use is a short session against your own debugging proxy on your own machine, where you know exactly who is re-signing. curl’s -k is the same trade, and curl’s docs (checked 2026-11-05) say never to skip verification in production. Search your codebase for verify=False before a release.

Updating certifi isn’t the fix either, at least for inspection. It carries public roots only. It does help when your bundle is years old and the site moved to a newer public CA.

What to check, in order

For an SSL certificate verify failed proxy error, stop at the first line that matches:

  1. Look at your proxy URL first when the exception wraps a ProxyError. An http:// proxy has no certificate to fail on, so https:// in the URL is the first thing to change.
  2. With a public CA on the i: line, update your bundle, then check the clock and the hostname.
  3. For a company or security product, get the root from its owner, build a combined bundle and set the variable your client actually reads.
  4. Trusted roots failing only on Python 3.13 or later call for a reissue, with the scoped flag above until it arrives.
  5. Stop sending credentials through it when the issuer is unknown and you don’t run the network.

Don’t put any of this in a retry loop. A certificate failure repeats until someone changes the configuration, so treat it as a config error and fail fast, unlike a 502 or a 429.

Frequently asked questions

Your client got a certificate during the TLS handshake and could not build a trusted chain from it. A plain CONNECT tunnel passes the site's certificate through untouched, so two other causes are more likely. One is a proxy that re-signed the traffic with its own root, and the other is an https:// proxy URL, which made the client check the proxy's certificate.

Append the inspecting proxy's root to certifi's bundle and set REQUESTS_CA_BUNDLE to the combined file, or pass verify with that path on each call. The root comes from whoever runs the proxy. Setting SSL_CERT_FILE has no effect on requests, so don't stop there if nothing changes.

They read different trust stores. A root pushed by IT lands in the operating system and browser, while requests uses the certifi bundle and ignores both. On Python 3.13 and later there is a second reason, since strict checking rejects some certificates that curl and Node accept.

No, not for anything real. Anything on the path can read your cookies and tokens once it accepts any certificate for any hostname. The one fair exception is a short session against your own debugging proxy on your own machine.

Only when your bundle is simply old and the site moved to a newer public CA. An inspecting proxy's root is private, so no certifi release will contain it.

Python 3.13 added VERIFY_X509_STRICT and VERIFY_X509_PARTIAL_CHAIN to its default TLS context. Reason text such as Missing Authority Key Identifier or CA cert does not include key usage extension gives it away. On a requests stack the flags arrive with urllib3 2.4.0, so a urllib3 upgrade on 3.13 can trigger it too. Ask for a reissued root, or for reissued site certificates when the reason is the missing identifier. Work that can't wait can clear the strict flag on one scoped context while keeping verification on.

Not if it only tunnels over CONNECT or SOCKS5, whichever IP type it uses, because that relays TLS and leaves the certificate alone. Check the path rather than guess, by running openssl s_client through the proxy and reading the issuer. Unblocker-style products can be the exception, since some vendors' docs ask you to load their certificate, though that wasn't tested here. An https:// scheme is an easy self-inflicted cause, so also confirm the proxy URL starts with http://.

Researched and drafted with AI tools, then checked against our publishing rules before it went live: 13 outside links, 5 links to other proxymint pages, no prices and a fact-check pass against our product records. How we write.