Fix SSL Certificate Errors in Python and Git

By Bug Circuit Security Team
Fix SSL Certificate Errors in Python and Git

Is your own website affected? Check it free in 2 minutes.

Passive outside check only. Nothing is attacked, no signup.

An SSL certificate error means your tool could not prove the server is who it claims to be, and the safe fix is to repair the trust problem (CA bundle, certificate chain, proxy certificate or system clock), not to switch verification off.

This post is for developers and site owners whose Python scripts, git clone commands or API tools (like Postman) stop with a certificate error. You will learn how to find the real cause in a few minutes, the exact fix for each cause, and what to do instead of verify=False.

What an SSL certificate error actually means

When a tool connects over HTTPS, the server sends a certificate. The tool checks three things: the certificate is not expired, the name matches the site, and it was signed by an authority the tool trusts. That authority is called a CA (certificate authority). The list of trusted CAs is the CA bundle (also called a trust store).

If any check fails, you get an error like these:

  • Python: requests.exceptions.SSLError: ... CERTIFICATE_VERIFY_FAILED: unable to get local issuer certificate
  • Git: fatal: unable to access 'https://...': SSL certificate problem: unable to get local issuer certificate
  • Postman: Unable to verify the first certificate or SSL Error: Self signed certificate in certificate chain

The error is a safety check doing its job. The goal is to learn which check failed. For background on how this trust model works, see the OWASP Transport Layer Security Cheat Sheet.

Quick diagnosis: find the cause in two commands

Run these from the same machine that shows the error. Replace example.com with your host.

# 1. Look at the dates and issuer
echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -dates -issuer

# 2. See the chain and the verify result
openssl s_client -connect example.com:443 -servername example.com -showcerts </dev/null 2>&1 | grep -E "Verify return code|verify error"

Then use this table.

What you seeLikely causeJump to
notAfter date is in the pastExpired certificateExpired certificate
unable to verify the first certificate or unable to get local issuer certificate, and browsers still workServer sends an incomplete chainIncomplete chain
Issuer is your employer, school or a security productProxy interceptionProxy interception
Verify return code: 0 (ok) in openssl, but Python failsPython's certifi bundle is older than your system store, so update certifi or use truststoreMissing CA bundle
Verify return code: 9 (certificate is not yet valid) or 10 (certificate has expired), but the certificate dates look currentYour system clock is wrongWrong clock
self-signed certificate on an internal serverPrivate CAPrivate or self-signed servers

Cause 1: missing or outdated CA bundle

Python's requests library uses the certifi package for its CA list. An old copy may not know newer CAs.

python -m pip install --upgrade certifi requests
python -m certifi   # prints the bundle file Python will use

Other fixes by situation:

  • macOS with a python.org installer: open the Python 3.x folder in Applications and run Install Certificates.command.
  • Debian or Ubuntu: sudo apt update && sudo apt install --reinstall ca-certificates, then sudo update-ca-certificates.
  • Use the operating system's trust store: on Python 3.10 or newer, the truststore package makes Python use the OS list, which also picks up certificates your IT team installed. It is not part of the standard library, so install it first:
python -m pip install truststore
import truststore
truststore.inject_into_ssl()

import requests
print(requests.get("https://example.com").status_code)

To point a tool at a specific bundle, use the environment variables the Requests documentation describes:

export REQUESTS_CA_BUNDLE=/path/to/ca-bundle.pem
export SSL_CERT_FILE=/path/to/ca-bundle.pem

Cause 2: expired certificate

If the notAfter date has passed, no client setting fixes it. The server owner must renew the certificate. If it is your site and you use Let's Encrypt, run sudo certbot renew and check that the renewal timer is running (systemctl list-timers | grep certbot). Then reload your web server.

If it is someone else's API, tell them. Do not work around an expired certificate on a production integration.

Cause 3: incomplete certificate chain

A server should send its own certificate plus the intermediate certificates that link it to a trusted root. Many servers forget the intermediates. Browsers often download the missing piece on their own, so the site looks fine. Python, curl and Git on Linux do not, so they fail. Git for Windows with schannel may fetch them, so it can behave differently.

If this is your server, serve the full chain. With Let's Encrypt and nginx:

ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

The common mistake is pointing at cert.pem instead of fullchain.pem. Reload the server, then rerun the openssl s_client check. You want Verify return code: 0 (ok). WordPress and Shopify owners rarely hit this, because the host manages the chain. If you do, ask your host to reinstall the certificate.

Cause 4: proxy interception

Some company networks, schools and antivirus tools inspect HTTPS traffic. They do this by re-signing every site with their own certificate. Your browser trusts it because IT installed the root certificate. Python (via certifi) and Git on Linux or default Git for Windows do not pick up certificates that IT installed only in your browser or Windows store.

The safe fix is to trust that one root certificate, not to disable checks:

  1. Ask IT for the root CA file in PEM format (a text file starting with -----BEGIN CERTIFICATE-----).
  2. Save it somewhere stable, like ~/certs/corp-root.pem.
  3. Point your tools at it (examples below), or use truststore for Python.

REQUESTS_CA_BUNDLE, SSL_CERT_FILE and Git's http.sslCAInfo replace the default bundle, they don't add to it. If you point them at only the proxy root, public sites will fail when you are off the proxy or VPN. To keep public CAs too, build a combined file: cat "$(python -m certifi)" ~/certs/corp-root.pem > ~/certs/combined.pem, then point the variables at combined.pem.

If you are on a personal network and see an unexpected issuer, stop. That could be a real interception attempt. Switch networks and retry before doing anything else.

Cause 5: wrong system clock

Certificates have start and end dates. If your clock is wrong (dead laptop battery, a VM that was paused, a container with drift), a valid certificate looks expired or not yet valid. Check with date -u, then sync it:

sudo timedatectl set-ntp true
timedatectl status

On Windows or macOS, turn on "Set time automatically" in the date and time settings.

SSL certificate error in Git

Start by updating Git, since older builds ship old CA bundles. Then get detail:

GIT_CURL_VERBOSE=1 git clone https://example.com/repo.git

Fixes that match the causes above:

  • Company proxy certificate: git config --global http.sslCAInfo /path/to/corp-root.pem (this replaces the default bundle, so use the combined file from Cause 4 if you also need public sites)
  • Git for Windows: use the Windows certificate store with git config --global http.sslBackend schannel
  • Private Git server with its own CA: limit the trust to that host only: git config --global http.https://git.internal.example/.sslCAInfo /path/to/internal-ca.pem

If someone told you to run git config --global http.sslVerify false, undo it:

git config --global --unset http.sslVerify

See the git-config documentation for every http.ssl* option.

SSL certificate error in Postman

Postman has its own certificate settings, separate from your browser. Menu names shift a little between versions, but the idea is the same:

  1. Open Settings, then Certificates.
  2. Under CA Certificates, turn the option on and choose your PEM file (the proxy root or private CA).
  3. Retry the request.

If you are behind a proxy, also check Settings > Proxy. Postman can turn off verification in Settings > General ("SSL certificate verification"). Treat that toggle like verify=False: fine for a throwaway local test, wrong for anything with real credentials or data. Postman's own certificate docs cover this.

How to bypass an SSL certificate error in Python (and why you shouldn't)

You will see this advice everywhere:

requests.get("https://example.com", verify=False)

It works, because it skips every check. That means your script will talk to anyone who can sit between you and the server, and it will not notice. An attacker on the same Wi-Fi or network could read or change the traffic, including API keys and tokens. This weakness has its own name, CWE-295: Improper Certificate Validation. The same goes for ssl._create_unverified_context() and for any code that sets CERT_NONE or check_hostname = False. Hiding the warning with urllib3.disable_warnings() does not make it safe either. It only stops the message.

The safe version of "bypass" is to tell Python exactly which certificate to trust:

requests.get("https://internal.example", verify="/path/to/internal-ca.pem")

This fixes self-signed and private-CA servers while keeping protection on. Disabling verification is only defensible for a local test against a server you control, on your own machine, with no real secrets. Even then, remove it before the code is committed.

Private or self-signed servers

For staging servers and internal tools, create or request a certificate from a CA your team trusts. For local development, a tool like mkcert creates a local CA and certificates that your machine trusts. Add the CA file to your tools as shown above. Do not copy a self-signed certificate into production clients without a plan to rotate it.

If it's your own website with the error

Your customers and API clients feel the same failure. Check these:

  • The certificate is not expiring soon, and auto-renewal works.
  • The server sends the full chain.
  • The certificate name covers www and the bare domain.
  • HTTP redirects to HTTPS, and your security headers are set.

A free website security check can flag some of these from the outside. For the bigger picture, read Is my website hackable?

Key takeaways

  • A certificate error is a trust check failing. Find which one with openssl s_client before changing anything.
  • Match the cause to the fix: update certifi or use truststore, renew the certificate, serve fullchain.pem, trust your proxy's root CA, or fix the clock.
  • In Git, use http.sslCAInfo (or schannel on Windows). In Postman, add a CA file under Settings > Certificates.
  • Avoid verify=False and sslVerify false. Pass the right CA file instead, and undo any global switch you set.
  • Fix the chain and renewal on your own sites, so your users and tools never see the error.

Want a human to check your site?

Certificate problems are one small part of website security. If you want a person to look at the whole site, a Bug Circuit Circuit audit is $49 one time. A security engineer reviews your site by hand and writes up every issue with severity, evidence and exact fixes. It is a focused small-site audit, not an enterprise pentest or a compliance certification.

Want certainty, not guesswork?

A real human security engineer audits your whole site by hand and sends a full report: every issue, its severity, and the exact fix. From $49, with a 14-day money-back guarantee.

See pricing

Frequently asked questions

How to fix SSL certificate error in Python?
First find the cause with `openssl s_client -connect host:443 -servername host`. Then update the CA bundle (`pip install --upgrade certifi`), install and use `truststore` on Python 3.10 or newer, or set `REQUESTS_CA_BUNDLE` to your proxy or private CA file. If the server's certificate is expired or its chain is incomplete, the server owner has to fix it.
How to bypass SSL certificate error in Python?
You can pass `verify=False` to `requests`, but that turns off all certificate checks and exposes your traffic to interception. The safer way is `verify="/path/to/ca.pem"`, which trusts only the certificate you name. Use `verify=False` only for a local test with no real secrets.
Why do I get an SSL certificate error in Git?
Usually Git cannot find a trusted CA for the server's certificate. Common reasons are an old CA bundle, a company proxy that re-signs HTTPS traffic, an incomplete chain on the server or a wrong system clock. Run `GIT_CURL_VERBOSE=1 git clone <url>` to see details, then set `http.sslCAInfo` to the right certificate file.
How do I fix an SSL certificate error in Postman?
Open Settings, then Certificates, and add the CA file (PEM format) that signed your server or proxy certificate. Also check Settings > Proxy and your system clock. Turning off SSL certificate verification works, but it removes protection, so keep it for local testing only.
Is it safe to disable SSL verification?
Not on real networks or with real data. Without verification, your tool cannot tell the real server from an attacker in the middle, so tokens and passwords could be read or changed. Trust the specific CA certificate instead.

Keep reading

See what attackers see, for free

Run the free passive check on your website. No login, no impact on your site, results in seconds.

Ready for the full manual audit? See pricing

Published by Bug Circuit. Written with AI assistance and reviewed for accuracy before publishing.