SSL certificate verify failed: fix it in Python, curl and Node
What you see
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificateSSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1125)'))requests.exceptions.SSLErrorcertificate verify failed: self-signed certificate in certificate chain
More error strings (10)
curl: (60) SSL certificate problem: unable to get local issuer certificateSSL certificate problem: self-signed certificate in certificate chainCURLE_PEER_FAILED_VERIFICATIONError: unable to verify the first certificateUNABLE_TO_VERIFY_LEAF_SIGNATURESELF_SIGNED_CERT_IN_CHAINUNABLE_TO_GET_ISSUER_CERT_LOCALLYDEPTH_ZERO_SELF_SIGNED_CERTCERT_HAS_EXPIREDnet::ERR_CERT_AUTHORITY_INVALID
What it means
Your code asked for an HTTPS page and got back a certificate (the site’s ID card) it did not trust. It hung up before sending your request. When you scrape, the certificate is often not the site’s at all: your proxy or unblocker made it up to read your traffic. The fix is almost always the same: trust the right CA file instead of switching the check off.
Why it happens
A certificate is trusted when a CA (a certificate authority, the company that vouches for it) in your trust list signed it. The check fails when that chain breaks somewhere. Most common first:
- Your proxy opens your HTTPS traffic. Unblocker APIs in proxy mode decrypt each request to work on it, then sign the page with their own CA. That CA is a stranger to your code:
- Bright Data (residential, Web Unlocker, SERP API in native proxy mode) gives you its CA file. The one in use is
brightdata_root_ca_44445.crtfor port44445. The old ones for ports 22225 and 33335 expired on 25 Sep 2026, 00:00 UTC, and traffic that still needs them fails. - Zyte API: Zyte says that if every request fails with a certificate error, you need to install its CA.
- Oxylabs Web Unblocker asks you to skip the check (
-kin curl or the same thing in your language). - mitmproxy and other debugging proxies make a fake certificate for every site, all signed by their own CA.
- Bright Data (residential, Web Unlocker, SERP API in native proxy mode) gives you its CA file. The one in use is
- Your code uses a different trust list than your computer. requests uses the
certifipackage. Python from python.org on macOS does not read the Keychain. Node uses its own bundled CAs. A CA you installed system-wide can work in Chrome and still fail in your code. - The site sends half its chain. Most certificates hang off a middle (“intermediate”) certificate. Browsers can fetch a missing one on their own. Python and Node cannot, so you get
unable to get local issuer certificateorunable to verify the first certificate. - The site’s certificate is just bad. It is self-signed, expired, or made for a different hostname. A wrong clock on your machine can make a good one look expired too.
The check starts with what the site sends: its own certificate plus the middle ones. Your client walks up that chain until it reaches a root it already trusts. No trusted root at the top means the check fails.
A proxy that reads your HTTPS has to stand in for the site. It fetches the page, then hands it to you under a certificate it made on the spot. It cannot sign as the real site, so it signs with its own CA. mitmproxy’s docs describe the same thing: a dummy certificate for every site you visit, trusted only after you install its CA.
To your code, that looks like an attack. Chromium’s notes list “an attacker” first among the reasons for this error. The difference is that you asked for it.
The browser-only trick: browsers can follow a link inside the certificate (AIA, “Authority Information Access”) to fetch a missing intermediate certificate. A CPython developer called that slow and not something to rely on. So the site works in Chrome and still fails in your scraper.
Fix it
- Read the reason after the colon.
self-signed certificate in certificate chainbehind a proxy usually means cause 1. The table further down matches each reason to its cause. - Test the same URL with curl and then without the proxy. If it works without the proxy, the proxy is the one signing. If curl works and your code fails, look at your code’s trust list (cause 2).
- Behind an unblocker or debugging proxy, trust its CA file:
- Python requests: put the vendor’s CA after a normal CA bundle in one file and then set
REQUESTS_CA_BUNDLEto it. - Node: start it using
NODE_EXTRA_CA_CERTS=/path/vendor-ca.crt. - curl: add
--cacert /path/vendor-ca.crt. - Chrome, Firefox or a tool that cannot load a file: install the CA in the system’s trusted root store. Bright Data and Zyte both list the clicks per OS.
- Python requests: put the vendor’s CA after a normal CA bundle in one file and then set
- CA already on your system (corporate network, local root CA)? Tell your tool to use the system store:
- Python 3.10+: the
truststorelibrary. - Node 23.8.0+:
--use-system-ca(orNODE_USE_SYSTEM_CA=1from 22.19.0 and 24.6.0). - curl:
--ca-native.
- Python 3.10+: the
- Python from python.org on macOS failing everywhere? Run
Install Certificates.commandfrom your Python folder first. - The site’s own chain is incomplete? Add the missing intermediate to your CA file.
- Turn the check off only where the vendor makes you.
verify=False,curl -kandNODE_TLS_REJECT_UNAUTHORIZED=0accept any certificate at all, so scope it to that one proxy call, never your whole program.
Why the CA file beats switching the check off: verify=False drops every check at once. Wrong host, expired, signed by anyone: all accepted. With the vendor’s CA loaded, your code still refuses a certificate that vendor did not issue, and every other check keeps running.
Where the file goes: on the machine that runs the scraper. Bright Data’s docs point out that on a cloud server, the server is the one that needs it, not your laptop. In most code you just load the file per call, with no install at all.
If you must turn it off, keep it small. In Python, verify=False sits on one call. In Node, NODE_TLS_REJECT_UNAUTHORIZED=0 turns off checks for TLS connections in the whole process. rejectUnauthorized: false goes in the options of one connection instead. Oxylabs’ Node sample sets the process-wide one.
Our advice: a new IP or a retry won’t help here. The same CA signs every answer from the same service, so just fix the trust list once.
Paste this into your AI
My scraper fails with this certificate error:
"<paste the full error line, including the text after 'certificate verify failed:' or the error code>"
Explain in plain words which certificate failed: the website's, my proxy's, or one a proxy made up in the middle.
List the likely causes in order, most likely first. For each, give one quick test and one fix.
Prefer fixes that keep verification on (trusting a CA file) over turning it off.
Show the curl -v command that tests the same URL through my proxy.
My setup: <Python requests / httpx / Node fetch / axios / curl / Playwright / Puppeteer> on <OS>,
proxy: <none / provider + product, e.g. unblocker API in proxy mode / company proxy / mitmproxy>,
CA settings: <default / REQUESTS_CA_BUNDLE / NODE_EXTRA_CA_CERTS / --cacert / verify=False>,
target URL pattern: <https://example.com/...>.
Never ask me to paste my real password.Dev details
The reason text tells you the cause
| reason (OpenSSL text) | Node err.code |
usual cause when scraping |
|---|---|---|
self-signed certificate in certificate chain |
SELF_SIGNED_CERT_IN_CHAIN |
proxy or unblocker signing with its own CA |
unable to get local issuer certificate |
UNABLE_TO_GET_ISSUER_CERT_LOCALLY |
your trust list is missing a CA (proxy’s, company’s, or a middle certificate) |
unable to verify the first certificate |
UNABLE_TO_VERIFY_LEAF_SIGNATURE |
the site sent only its own certificate, no chain |
self-signed certificate |
DEPTH_ZERO_SELF_SIGNED_CERT |
the site signed its own certificate |
certificate has expired |
CERT_HAS_EXPIRED |
expired certificate, or your clock is wrong |
hostname mismatch |
HOSTNAME_MISMATCH |
certificate made for another name |
OpenSSL’s own docs:
unable to get local issuer certificate: “the list of trusted certificates is not complete”.self-signed certificate in certificate chain: the chain was built, but no trusted root was found.unable to verify the first certificate: the chain holds only one certificate, it is not self-signed and partial chains are not allowed.
Real messages
SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1125)')))
curl: (60) SSL certificate problem: unable to get local issuer certificate
Error: unable to verify the first certificate
at TLSSocket.onConnectSecure (_tls_wrap.js:1496:34)
...
code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'
}
curl (error 60)
60 means CURLE_PEER_FAILED_VERIFICATION: “The remote server’s SSL certificate or SSH fingerprint was deemed not OK.” curl prints SSL certificate problem: <reason>, points to https://curl.se/docs/sslcerts.html and says “curl failed to verify the legitimacy of the server and therefore …”.
# Bright Data native proxy mode, CA loaded per call
curl --proxy brd.superproxy.io:44445 \
--proxy-user brd-customer-<account-id>-zone-<zone-name>:<zone-password> \
--cacert /path/brightdata_root_ca_44445.crt "https://geo.brdtest.com/mygeo.json"
# mitmproxy
curl --proxy 127.0.0.1:8080 --cacert ~/.mitmproxy/mitmproxy-ca-cert.pem https://example.com/
# certificates the server actually sends
curl -w %{certs} https://example.com > cacert.pem
--cacertand-kact on the site’s certificate. For TLS to anhttps://proxy itself, curl uses--proxy-cacertand--proxy-insecure.CURL_CA_BUNDLE,SSL_CERT_FILEandSSL_CERT_DIRalso point curl at a CA file when it has no native store.- Apple SecTrust builds:
--cacertalone means just that file is trusted. Use--ca-native --cacert filefor both. - Windows Schannel builds use the Windows store. Bright Data says if curl on Windows fails on port 44445 with
CRYPT_E_REVOCATION_OFFLINE, add--ssl-revoke-best-effort. - curl’s advice on
-k: avoid it and “never skip verification in production”.
Python requests
# cacert.pem = the Mozilla CA bundle from curl's "CA Extract" page
cat cacert.pem vendor-ca.crt > ca-bundle.pem
export REQUESTS_CA_BUNDLE="$PWD/ca-bundle.pem" # CURL_CA_BUNDLE is the fallback
Zyte’s advice is to append the vendor CA to a generic bundle.
import requests
requests.get("https://example.com", proxies=proxies, verify="/path/ca-bundle.pem")
verify=takes a CA bundle file, or a folder processed by OpenSSL’sc_rehash.- Prepared requests (
s.send(prepped)) ignore environment settings, soREQUESTS_CA_BUNDLEis skipped and you getCERTIFICATE_VERIFY_FAILED. Merge them in:settings = s.merge_environment_settings(prepped.url, {}, None, None, None), thens.send(prepped, **settings). verify=Falsemakes requests accept any certificate and ignore hostname mismatches and expired certificates.- One report: a custom
ssl_contextadapter that loaded Windows system CAs worked on requests 2.31.1 and failed on 2.32.x. The reporter ties it to 2.32.0, whereverify=Truebegan reusing one global SSL context. - Python’s
sslmodule needs the server to send the full chain, and a CPython issue asking for browser-style fetching of missing middle certificates has been open since 1 Aug 2013.
import truststore
truststore.inject_into_ssl() # Python 3.10+; as early as possible; apps only, not libraries
import requests
More about proxies and SSLError in Python: Python requests ProxyError.
Node.js
NODE_EXTRA_CA_CERTS=/path/vendor-ca.crt node scraper.js
node --use-system-ca scraper.js
NODE_EXTRA_CA_CERTSadds PEM certificates to Node’s built-in roots. It is read once at startup, so settingprocess.env.NODE_EXTRA_CA_CERTSin code has no effect.- Passing a
caoption to a TLS or HTTPS client drops both the built-in and the extra certificates. - On errors like
UNABLE_TO_VERIFY_LEAF_SIGNATURE, Node adds a hint to try--use-system-caif the root CA is installed locally. rejectUnauthorized: falseorNODE_TLS_REJECT_UNAUTHORIZED=0turn the check off. Node’s docs call the variable “strongly discouraged”. Oxylabs’ Node sample sets it from inside the script.
Browsers: ERR_CERT_AUTHORITY_INVALID
Chromium error -202 means a certificate was signed by an authority it does not trust. Its own notes give 3 options: an attacker, a real CA Chrome doesn’t know, or a self-signed certificate. Through an unblocker, it is the second.
// Playwright
const context = await browser.newContext({ ignoreHTTPSErrors: true });
// Puppeteer
const browser = await puppeteer.launch({ acceptInsecureCerts: true });
Or install the vendor’s CA in your system or browser store, following what Bright Data and Zyte describe, and keep the check on.
Vendor CA cheat sheet
| service | what its docs say |
|---|---|
| Bright Data, native proxy mode | load brightdata_root_ca_44445.crt per call (--cacert) or install it; port 44445; can skip it via the proxy API or after KYC |
| Zyte API, proxy mode | install the Zyte CA; Node: NODE_EXTRA_CA_CERTS; requests: CA bundle + REQUESTS_CA_BUNDLE; Java: keytool truststore |
Oxylabs Web Unblocker (unblock.oxylabs.io:60000) |
ignore the certificate: curl -k, verify=False, NODE_TLS_REJECT_UNAUTHORIZED = 0 |
| mitmproxy | trust ~/.mitmproxy/mitmproxy-ca-cert.pem, or install it from mitm.it |
Why the same words show up in Python, Node.js and curl: all three hand the check to OpenSSL (curl when built with it). Node’s docs say err.code holds the OpenSSL error code. curl prints OpenSSL’s text after SSL certificate problem:. Python’s message carries the same text after certificate verify failed:. That is why one table covers all three.
curl numbers changed once: since curl 7.62.0, CURLE_PEER_FAILED_VERIFICATION and CURLE_SSL_CACERT are one error, 60. Before that, a failed peer check was reported as 51.
Error 77 is a different problem: CURLE_SSL_CACERT_BADFILE, “Problem with reading the SSL CA cert (path? access rights?)”. Your CA file never loaded. So check the path and permissions first, before you look at the server.
Questions
Why does the site open fine in my browser but fail in Python?
Two common reasons. Your code may use its own list of trusted CAs, not your computer's: requests uses the certifi package, and Node uses its bundled list unless you pass --use-system-ca. Or the site leaves out a middle certificate: browsers can download it themselves, Python's ssl module needs the server to send the full chain.
Is verify=False safe with an unblocker API?
It makes your code accept any certificate, expired or for the wrong host. The requests docs say that leaves you open to man-in-the-middle attacks. Oxylabs Web Unblocker asks you to skip the check. Bright Data and Zyte give you their CA file instead, so the check can stay on.
Do I need Bright Data's SSL certificate?
Only in native proxy mode. Bright Data says you can work without it through its proxy API, or once your account passes its KYC check. With it, use brightdata_root_ca_44445.crt on port 44445: the old certificates for ports 22225 and 33335 expired on 25 Sep 2026.
Related
- Python web scraping Guide
- Scrape a JavaScript website with Playwright, and when not to Guide
- Rotating proxies Guide
- Scraper and unblocker APIs Compare
- Proxy checker Free tool
- 407 Proxy Authentication Required Error
Tools that get past it
| Tool | Price |
|---|---|
| $8.00/GB | |
| $7.20/GB | |
| Free | |
| Free | |
| Free | |
| $0.13/1k req |
Sources
curl docs: TLS Certificate Verification (--cacert, --ca-native, -k, HTTPS proxy) curl.se
libcurl: error codes (CURLE_PEER_FAILED_VERIFICATION, 60) curl.se
curl source: vtls/openssl.c ('SSL certificate problem: %s') github.com
curl source: tool_operate.c (error 60 help text) github.com- Stack Overflow: curl: (60) SSL certificate problem: unable to get local issuer certificate stackoverflow.com
- OpenSSL docs: certificate verify error codes and strings docs.openssl.org
Requests docs: SSL Cert Verification, CA Certificates (certifi), prepared requests requests.readthedocs.io
psf/requests issue #6717: SSLCertVerificationError with a local root CA on 2.32.x github.com
CPython issue #62817: AIA chasing for missing intermediate certificates github.com
Truststore docs: system certificate stores for Python 3.10+ truststore.readthedocs.io
Node.js docs: TLS, X509 certificate error codes, rejectUnauthorized nodejs.org
Node.js docs: NODE_EXTRA_CA_CERTS, --use-system-ca, NODE_USE_SYSTEM_CA, NODE_TLS_REJECT_UNAUTHORIZED nodejs.org
nodejs/node issue #33705: UNABLE_TO_VERIFY_LEAF_SIGNATURE caused by a missing chain github.com
Chromium source: net_error_list.h (CERT_AUTHORITY_INVALID, -202) chromium.googlesource.com
Playwright docs: Browser, ignoreHTTPSErrors playwright.dev
Puppeteer docs: ConnectOptions, acceptInsecureCerts pptr.dev
Puppeteer docs: LaunchOptions (extends ConnectOptions) pptr.dev
Bright Data Docs: SSL certificate (port 44445, old ports expired 25 Sep 2026) docs.brightdata.com
Zyte docs: Installing the Zyte CA certificate docs.zyte.com
Oxylabs Docs: Web Unblocker (ignore the SSL certificate) developers.oxylabs.io
Oxylabs Docs: Web Unblocker, Making Requests (code samples) developers.oxylabs.io
mitmproxy docs: About Certificates docs.mitmproxy.org