Troubleshooting

unable to get local issuer certificate: fix it in curl, git, Python and Node.js

unable to get local issuer certificate in curl, git, pip or npm: check the CA bundle, the server's intermediate and proxy CAs; never turn verification off.

Published ~8 min read
On this page

Short answer: unable to get local issuer certificate means the client followed the server's certificate up its chain and could not find the certifying CA in its own trust store. Check three things in this order: the client has a CA bundle at all, the server sends its intermediate certificate, and nothing between you and the server (a company proxy, an antivirus) swaps the certificate for its own.

Linux · macOS · WSL: find out which of the three it is
# 1. Which CA file does curl use, and does verification fail?
curl -sv https://example.com -o /dev/null 2>&1 | grep -E 'CAfile|CApath|issuer|problem'

# 2. What chain does the server send? (one s:/i: pair per certificate)
openssl s_client -connect example.com:443 -servername example.com -showcerts </dev/null 2>/dev/null \
  | grep -E '^ [0-9] s:|^   i:|Verify return code'

# 3. Where does Python look?
python3 -c "import ssl; print(ssl.get_default_verify_paths())"

Replace example.com with the host that fails. If step 2 lists only certificate 0 and ends in Verify return code: 21 (unable to verify the first certificate), the server is missing its intermediate. If the issuer on the last line names your employer, school or antivirus, the connection is being inspected. Every error message below was produced on our Debian 12 host (curl 7.88.1, OpenSSL 3.0.22, Git 2.39.5, Python 3.11.2 with requests 2.28.1, Node.js 26.12.1) against a test server we started on 127.0.0.1 with a throwaway root, intermediate and leaf certificate.

What the error means

A server certificate is signed by an intermediate CA, and the intermediate is signed by a root CA. Your client trusts a fixed list of roots, the CA bundle. To verify a site it needs the full path from the server's certificate to one of those roots. The word local is the hint: OpenSSL looked in the local store for the certificate that signed the last one it had, and found nothing. OpenSSL reports it as verify error:num=20, and every client built on OpenSSL passes the same text on.

CauseHow it showsWhere to fix it
No CA bundle, or an old oneEvery HTTPS site fails from this machine or containerClient: install or update ca-certificates
Server sends no intermediateFails in curl, Python, Node; often fine in a desktop browser. s_client shows one certificate and code 21Server: serve the full chain
Proxy or antivirus inspects TLSEvery site fails at work or with one program installed; the issuer is a company or product nameClient: trust the inspecting CA
Private or self-made CAOnly internal hosts failClient: add that root, scoped to what needs it

The same error in curl, git, Python and Node.js

Each tool words it differently and, more important, reads a different trust store. That is why curl can work while pip fails on the same machine.

ToolError we gotTrust store it readsPoint it at a CA file
curlcurl: (60) SSL certificate problem: unable to get local issuer certificateThe CAfile and CApath it was built with (curl -v prints both)--cacert FILE or CURL_CA_BUNDLE
git (Debian, GnuTLS build)server certificate verification failed. CAfile: none CRLfile: noneThe system storegit config http.sslCAInfo FILE or GIT_SSL_CAINFO
Python requests, pip[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificatecertifi; pip 24.2 and later add the system storeREQUESTS_CA_BUNDLE, pip --cert or PIP_CERT
Python urllibSame text inside urlopen errorOpenSSL defaults (ssl.get_default_verify_paths())SSL_CERT_FILE
Node.js, npmUNABLE_TO_GET_ISSUER_CERT_LOCALLYNode's bundled Mozilla listNODE_EXTRA_CA_CERTS or --use-system-ca

Git prints the error text of the libcurl it was built with, so a Git whose libcurl uses OpenSSL (for example Git for Windows with http.sslBackend set to openssl) shows the curl wording instead: SSL certificate problem: unable to get local issuer certificate. Node reports a missing intermediate with a different code, UNABLE_TO_VERIFY_LEAF_SIGNATURE; the Node.js 26.12.1 on our host also suggested --use-system-ca in that message.

Fix order: work from the client to the server

  1. 1Make sure a CA bundle exists

    If every HTTPS site fails, the store is missing or stale. Minimal container images can ship without it (Docker's own buildpack-deps:curl image installs ca-certificates on top of debian:bookworm); on Debian and Ubuntu the store lives in /etc/ssl/certs/ca-certificates.crt.

  2. 2Check the chain the server sends

    If only one host fails, run the openssl s_client line from the top. A single certificate whose issuer is an intermediate means the server is at fault, and no client setting is the real fix.

  3. 3Look for TLS inspection

    If the issuer is not a public CA you recognise, something on your network signs certificates on the fly. Get its root certificate from whoever runs it.

  4. 4Trust the right root, in the right place

    Add the private or proxy root to the system store first, then tell the tools that keep their own list where to find it.

Cause 1: the client has no CA bundle

Debian · Ubuntu (also a Dockerfile RUN line)
apt-get update && apt-get install -y --no-install-recommends ca-certificates
  • Python from python.org on macOS: run Install Certificates.command in the /Applications/Python 3.x/ folder. The Python docs say it downloads and installs SSL root certificates (the certifi package) for that Python, and that it needs to run only once.
  • Python requests: uses the certifi package, so an old certifi means old roots. On Debian the packaged certifi points at the system file (on our host certifi.where() returns /etc/ssl/certs/ca-certificates.crt); in a venv with certifi from PyPI it is a separate copy.
  • pip: the pip docs say pip 24.2 and later use the system certificates in addition to certifi, so upgrading an old pip in a venv is often enough. Debian 12 ships pip 23.0.1.
  • Git for Windows: git config --global http.sslBackend schannel makes Git use the Windows certificate store, which already holds roots your IT department deployed (per git-config(1), schannel then ignores http.sslCAInfo unless http.schannelUseSSLCAInfo is set).

Cause 2: the server does not send its intermediate

This is the case that confuses people: the site loads in a browser, yet curl, a webhook or a Python job fails. Browsers can hide the gap; Firefox, for example, preloads the known public intermediate certificates, per Mozilla's security blog. Our test server sent only its own certificate, and openssl s_client showed exactly that:

output · leaf only, root passed with -CAfile
verify error:num=20:unable to get local issuer certificate
verify error:num=21:unable to verify the first certificate
 0 s:CN = localhost
   i:CN = Scratch Test Intermediate
Verify return code: 21 (unable to verify the first certificate)

Note what did not help: passing the correct root with curl --cacert root.pem, verify="root.pem" in requests or NODE_EXTRA_CA_CERTS still failed, because the missing link sits between the root and the leaf. Once the server sent leaf plus intermediate, all three succeeded with the same root. The fix belongs on the server: point nginx's ssl_certificate at fullchain.pem, not cert.pem. The details per web server are in SSL handshake failed, and a full nginx setup with certbot in nginx reverse proxy with SSL.

Cause 3: a company proxy or antivirus re-signs the traffic

TLS inspection decrypts your traffic and re-encrypts it with a certificate signed by the inspector's own root. Browsers on managed machines trust that root because IT installed it in the system store, but tools with their own list do not. Read the issuer:

any shell with openssl
openssl s_client -connect pypi.org:443 -servername pypi.org </dev/null 2>/dev/null \
  | openssl x509 -noout -issuer

A public CA name means no inspection. A company or product name means you need that root as a PEM file. On Debian and Ubuntu, update-ca-certificates(8) takes one certificate per file with a .crt extension in /usr/local/share/ca-certificates:

Debian · Ubuntu · add a root to the system store
sudo cp corp-root.pem /usr/local/share/ca-certificates/corp-root.crt
sudo update-ca-certificates

Then the tools that ignore the system store:

bash · per tool
# Python requests and pip: the file REPLACES certifi, so use the full system bundle
export REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
pip install --cert /etc/ssl/certs/ca-certificates.crt PACKAGE

# Node.js and npm: adds to Node's own list instead of replacing it
export NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/corp-root.crt
node --use-system-ca app.js      # or read the system store (Node 23.9 and later on Linux)

# git: one host only, so other hosts keep the normal store
git config --global http.https://git.corp.example.sslCAInfo /etc/ssl/certs/ca-certificates.crt

A private CA for internal services

The same commands apply to a CA you run yourself. Scope it as narrowly as you can: a per-host git setting, a verify= path in the one script that talks to the internal API, NODE_EXTRA_CA_CERTS in one service unit. Our run confirmed that CURL_CA_BUNDLE, REQUESTS_CA_BUNDLE and SSL_CERT_FILE (for urllib) each turned the failure into a working request, and git -c http.sslCAInfo=root.pem got git past certificate verification.

Never switch verification off as the fix

ToolTurns verification offUse instead
curl-k / --insecure--cacert FILE
githttp.sslVerify=falsehttp.sslCAInfo FILE
Python requestsverify=Falseverify="/path/bundle.pem"
pip--trusted-host HOST--cert FILE
Node.jsNODE_TLS_REJECT_UNAUTHORIZED=0NODE_EXTRA_CA_CERTS=FILE
npmstrict-ssl=falseNODE_EXTRA_CA_CERTS=FILE

Every flag in the middle column accepts any certificate, including an attacker's, and such lines tend to stay in scripts and CI files for years. The requests docs warn that verify=False leaves the application open to man-in-the-middle attacks. If the server is broken, fix the server; if your network inspects TLS, trust its root on purpose.

On a VPS or dedicated server

The error on a server usually comes from one of two places. Outgoing calls from a minimal image or container fail because ca-certificates was never installed; curl then often stops even earlier, with curl: (77) error setting certificate file for the missing bundle. Incoming calls from payment providers, monitoring or other servers fail because your own web server sends cert.pem instead of the full chain. Test your own host from outside with the openssl s_client line above after every certificate change; a renewal that swaps the file path is enough to break it. For more request options see curl command examples, and if the error says certificate has expired instead, check the clock first with ERR_CERT_DATE_INVALID.

Frequently asked

What does unable to get local issuer certificate mean?

The client could not build a path from the server's certificate to a root CA in its own trust store. Either the store is missing or old, the server did not send its intermediate certificate, or a proxy re-signed the connection with a root the client does not know.

Why does the site work in my browser but curl or Python fails?

Browsers can fill the gap themselves (Firefox, for example, preloads the known public intermediate certificates), while curl, Python and Node.js do not fetch a missing intermediate. Run openssl s_client with -showcerts against the host: if it lists a single certificate and ends in verify return code 21, the server must serve its full chain.

How do I fix it for pip and Python requests behind a company proxy?

Get the proxy's root certificate as a PEM file and add it to the system store, then set REQUESTS_CA_BUNDLE, or pass pip --cert, pointing at the full system bundle such as /etc/ssl/certs/ca-certificates.crt. Both replace the default list, so pointing them at the proxy root alone breaks public sites.

Is it safe to use curl -k or verify=False to get past the error?

No. Those options accept any certificate, including one from an attacker, and they tend to stay in scripts long after the test. Use --cacert, verify with a bundle path or NODE_EXTRA_CA_CERTS to trust the one CA you need, or fix the server's chain.

Related articles

All troubleshooting