Python `requests` fails with `SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain`.
BeginnerTroubleshootingTLS and certificate errors
Answer
Likely causes → A corporate TLS-inspection proxy or a private CA. requests uses certifi's bundle, not the OS trust store.
Diagnose →
python -c "import certifi; print(certifi.where())"
openssl s_client -connect pypi.org:443 -servername pypi.org -showcerts </dev/null | grep 'i:'
Fix → Point at the right bundle: export REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt (after adding the corporate CA to the OS store), or install truststore/pip-system-certs. Never set verify=False in production.
Prevent → Bake the corporate CA into base images and set REQUESTS_CA_BUNDLE, NODE_EXTRA_CA_CERTS and the Java truststore in one place.
More on TLS and certificate errors
`curl: (60) SSL certificate problem: certificate has expired`Beginner`curl: (60) SSL certificate problem: unable to get local issuer certificate`Beginner`SSL: no alternative certificate subject name matches target host name 'api.example.com'`BeginnerSome clients get the wrong certificate (another site's) from a shared IP.Intermediate`SSL routines::sslv3 alert handshake failure` from `openssl` or curl.IntermediateNode.js app logs `Error: unable to verify the first certificate` calling an internal API.Intermediate