"Unable to get local issuer certificate" means the TLS client could not build a chain from the server's certificate to a root CA it trusts. In practice there are three causes: a corporate TLS-inspection proxy (or private CA) whose root is not in the trust store that particular tool uses, a server that does not send its intermediate certificate, or a runtime such as Node.js or Python requests that ignores your operating system's trust store and uses its own bundle. The fix is to give the right tool the right CA certificate, through NODE_EXTRA_CA_CERTS, REQUESTS_CA_BUNDLE, http.sslCAInfo and similar settings, or to fix the server's chain. Turning verification off is never the fix.

I reproduced every error in this guide locally with a private root CA, an intermediate and three small HTTPS servers (OpenSSL 4.1, Node.js 24.15, Python 3.12 with requests 2.34, curl 8.7 and Git 2.54), so the messages below are real output, not paraphrases.

These three messages look alike but point to different problems:

Error text OpenSSL code Node.js err.code What is actually wrong
unable to get local issuer certificate 20 UNABLE_TO_GET_ISSUER_CERT_LOCALLY The chain leads to a CA your client does not trust
unable to verify the first certificate 21 UNABLE_TO_VERIFY_LEAF_SIGNATURE The server sent only its own certificate, no intermediate
self-signed certificate in certificate chain 19 SELF_SIGNED_CERT_IN_CHAIN The server (or proxy) sent its root too, and that root is not trusted

Here is how my test servers produced them in Node.js 24:

$ node client.js https://localhost:8441/
UNABLE_TO_GET_ISSUER_CERT_LOCALLY - unable to get local issuer certificate
$ node client.js https://localhost:8442/
UNABLE_TO_VERIFY_LEAF_SIGNATURE - unable to verify the first certificate; if the root CA is installed locally, try running Node.js with --use-system-ca
$ node client.js https://localhost:8443/
SELF_SIGNED_CERT_IN_CHAIN - self-signed certificate in certificate chain

Server 8441 sent leaf plus intermediate, 8442 sent only the leaf, and 8443 sent leaf, intermediate and root. The second and third errors are the same underlying problem as the first, untrusted root, seen from a different angle, except that "unable to verify the first certificate" can also happen with a perfectly trusted root when the server's chain is incomplete. Notice that Node 24 now suggests --use-system-ca directly in the error message.

Diagnose With openssl s_client -showcerts

Before changing any configuration, find out which certificates the server actually sends and who issued them:

openssl s_client -connect api.example.com:443 -servername api.example.com -showcerts </dev/null

Look at three things in the output. The chain listing (s: is subject, i: is issuer):

 0 s:CN=localhost
   i:CN=Corp Issuing CA 1
 1 s:CN=Corp Issuing CA 1
   i:CN=Corp Inspection Root CA

The verify errors, which name the depth where the chain broke:

depth=1 CN=Corp Issuing CA 1
verify error:num=20:unable to get local issuer certificate

And the final verdict, Verify return code: 20 (unable to get local issuer certificate). When I pointed the same command at the server that omitted its intermediate, the chain had only entry 0 and the return code was 21 (unable to verify the first certificate).

The issuer names answer the most important question: is something on your network intercepting TLS? If you connect to registry.npmjs.org or pypi.org and the top issuer is your company's name, or a security vendor's inspection CA, rather than a public CA, a proxy is re-signing traffic. Run the same command from a network outside the office (a phone hotspot works) and compare. Same public issuer outside, corporate issuer inside: it is interception, and every tool on your laptop needs that corporate root.

To save each certificate the server sends into its own file:

openssl s_client -connect api.example.com:443 -servername api.example.com -showcerts </dev/null 2>/dev/null \
  | awk '/-----BEGIN CERTIFICATE-----/{n++; f="chain-" n ".pem"} f{print > f} /-----END CERTIFICATE-----/{f=""}'

for f in chain-*.pem; do openssl x509 -in "$f" -noout -subject -issuer -fingerprint -sha256; done

Confirm a fix before touching any tool by passing the candidate root to s_client. With my test root, -CAfile root.pem turned the result into Verify return code: 0 (ok).

Get the right root certificate

For a corporate proxy, do not trust whatever the network hands you. Get the root from your IT or security team, or export it from a managed laptop's trust store, and check its SHA-256 fingerprint with them. On macOS:

security find-certificate -a -p -c "Corp Inspection Root CA" /Library/Keychains/System.keychain > corp-root.pem
openssl x509 -in corp-root.pem -noout -subject -fingerprint -sha256

On Windows, export it from certlm.msc under Trusted Root Certification Authorities as "Base-64 encoded X.509 (.CER)", which is PEM.

Which Trust Store Does Each Tool Use?

This is the root of most confusion. Your browser works because it uses the OS store, which IT already populated. Command-line tools often do not.

Tool Default trust source Add a CA without replacing the defaults
Node.js (and npm, yarn, pnpm) Mozilla CA list compiled into Node NODE_EXTRA_CA_CERTS=/path/corp-root.pem, or --use-system-ca
Python requests The certifi package bundle Build a combined bundle and set REQUESTS_CA_BUNDLE
Python ssl / urllib OpenSSL's default paths for that Python build SSL_CERT_FILE or truststore
pip 24.2+ System store (via truststore) plus certifi Usually works once the OS trusts the CA
curl Depends on how curl was built --cacert, CURL_CA_BUNDLE, or the OS store
Git (HTTPS) Its TLS backend's CA bundle git config http.sslCAInfo, or schannel on Windows

Fix It in Node.js: NODE_EXTRA_CA_CERTS and --use-system-ca

Node.js ships its own copy of the Mozilla root list and, by default, ignores the operating system store. Two supported ways to add your CA:

# Option 1: add specific PEM certificates on top of Node's bundled roots
export NODE_EXTRA_CA_CERTS=/etc/ssl/corp/corp-root.pem
node app.js

# Option 2: also trust the OS certificate store
node --use-system-ca app.js
# or, for every node process including npm:
export NODE_USE_SYSTEM_CA=1

With my test root in NODE_EXTRA_CA_CERTS, the first and third servers above returned OK, while the server missing its intermediate still failed with UNABLE_TO_VERIFY_LEAF_SIGNATURE, because trusting a root does not fix an incomplete chain.

Details from the Node.js CLI documentation that matter in practice:

  • NODE_EXTRA_CA_CERTS is read once, at process start. Setting process.env.NODE_EXTRA_CA_CERTS inside your code does nothing.
  • Neither the bundled roots nor the extra certificates are used when code passes an explicit ca option to a TLS or HTTPS client. If one library still fails, look for a hard-coded ca.
  • It is ignored when Node runs setuid root or with Linux file capabilities.
  • --use-system-ca was added in v23.8.0 and v22.15.0, with support on Linux and other non-Windows, non-macOS platforms arriving in v23.9.0. The NODE_USE_SYSTEM_CA=1 environment variable arrived in v24.6.0 and v22.19.0. On macOS it respects certificates marked "Always Trust" in the default and system keychains; on Windows it reads the Local Machine Trusted Root Certification Authorities.

If you are moving to a newer Node release anyway, our Node.js 26 LTS upgrade guide covers the rest of the changes.

npm, yarn and pnpm

npm runs on Node, so NODE_EXTRA_CA_CERTS fixes it too. In my test, npm view left-pad version against the intercepted registry failed with npm error code UNABLE_TO_GET_ISSUER_CERT_LOCALLY; with the variable set, the TLS error disappeared.

npm also has cafile and ca settings, but be careful: the npm config docs describe ca as trusting "only that specific signing authority". Point it at just your corporate root and public registries can break. If you use cafile, make it a combined bundle of public roots plus your CA. I prefer the environment variable because it adds rather than replaces.

Fix It in Python: requests, certifi, truststore and pip

requests does not read the OS trust store by default. It uses certifi, a copy of the Mozilla bundle installed in your virtual environment:

requests.exceptions.SSLError: ... [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1010)

REQUESTS_CA_BUNDLE fixes it, but it replaces the bundle rather than adding to it. Pointing it at only your corporate root breaks every site that is not behind the proxy. Build a combined file:

cat "$(python -m certifi)" /etc/ssl/corp/corp-root.pem > ~/.config/corp-ca-bundle.pem
export REQUESTS_CA_BUNDLE=~/.config/corp-ca-bundle.pem

I tested exactly this: with the combined bundle, the same script fetched my intercepted test server and https://pypi.org successfully. Remember that upgrading certifi does not update your copied file, so regenerate it occasionally.

For applications (not libraries), the cleaner fix is truststore, which makes Python verify against the operating system's store: the Security framework on macOS, CryptoAPI on Windows and OpenSSL's system paths on Linux. It requires Python 3.10 or later:

import truststore
truststore.inject_into_ssl()   # call this before importing requests, urllib3 or aiohttp

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

truststore's documentation is emphatic that inject_into_ssl() "must not be used by libraries or packages"; libraries should pass a truststore.SSLContext explicitly.

pip already does this. Since pip 24.2, it uses system certificates via truststore in addition to certifi by default, according to the pip HTTPS certificates docs. That is why pip install often works on a corporate laptop while your requests-based script fails. For older pip, --cert or PIP_CERT points pip at a bundle.

Two more Python gotchas:

  • Python 3.13 and later are stricter. ssl.create_default_context() now sets VERIFY_X509_STRICT and VERIFY_X509_PARTIAL_CHAIN by default. Badly formed private CA certificates, such as a root without critical Basic Constraints, can start failing after an upgrade even though they worked on 3.12. The right fix is a properly issued CA, not clearing the flag.
  • python.org installers on macOS do not use the system keychain for the standard ssl module. Run the bundled "Install Certificates.command" once after installing, or use truststore.

If you are planning the move to newer Python versions, see Python 3.15 What's New.

Fix It in curl and Git

curl's error is the classic form:

curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.se/docs/sslcerts.html

Pass the CA for one request, or set it for the session:

curl --cacert /etc/ssl/corp/corp-root.pem https://internal.example.com/
export CURL_CA_BUNDLE=/etc/ssl/corp/corp-ca-bundle.pem

Which store curl uses by default depends on how it was built (OpenSSL, LibreSSL, Schannel, Secure Transport), so curl --version is worth checking when two machines behave differently.

Git over HTTPS fails the same way, fatal: unable to access 'https://...': SSL certificate problem: unable to get local issuer certificate. Scope the fix to the one host that needs it:

# only for the internal Git server
git config --global http.https://git.corp.example.com/.sslCAInfo /etc/ssl/corp/corp-root.pem

# Windows: use the Windows certificate store, which IT already manages
git config --global http.sslBackend schannel

In my test, git -c http.sslCAInfo=root.pem ls-remote got past TLS and reached the server, while the same command without it failed with the error above.

Add the CA to the Operating System Store

Once the OS trusts the root, many tools follow automatically: pip, Node with --use-system-ca, Python with truststore, curl builds that use the system store, and Git on Windows with schannel.

# Debian / Ubuntu (file must end in .crt)
sudo cp corp-root.pem /usr/local/share/ca-certificates/corp-root.crt
sudo update-ca-certificates

# Fedora / RHEL / Amazon Linux
sudo cp corp-root.pem /etc/pki/ca-trust/source/anchors/
sudo update-ca-trust

# macOS
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain corp-root.pem

In containers, do this in the image build, not at runtime, and keep the CA file in the build context rather than downloading it.

When the Server Is the Problem: Missing Intermediate Certificates

If openssl s_client -showcerts lists only certificate 0 and returns code 21, the server is misconfigured. Browsers often hide this because they cache intermediates or fetch them from the certificate's AIA URL, so "it works in Chrome" proves nothing. Command-line clients do not do that.

The fix is on the server: configure it with the full chain (leaf followed by intermediates). For nginx that means ssl_certificate points to fullchain.pem, not cert.pem. If you are automating renewals for shorter certificate lifetimes, make sure the deploy hook installs the full chain every time; our guide to 47-day TLS certificates covers that automation, and the post-quantum TLS on nginx guide shows the rest of a modern nginx TLS block.

Why You Should Never Disable Certificate Verification

Every tool has an escape hatch: NODE_TLS_REJECT_UNAUTHORIZED=0, verify=False, curl -k, git config http.sslVerify false, npm config set strict-ssl false. Each one removes the only thing that proves you are talking to the real server. On a corporate network, the next proxy, compromised Wi-Fi or poisoned DNS entry gets your credentials, tokens and package downloads, and the setting tends to survive long after the original problem, often committed into a Dockerfile or CI config.

The proper fixes above take about the same time as the insecure ones. If you need a workaround for five minutes of debugging, scope it to a single command and never to a shell profile, global config or image.

Frequently Asked Questions

What does "unable to get local issuer certificate" mean?

The client received a certificate chain but could not find the issuing CA in its own (local) trust store, so it could not verify the server. It usually means a corporate proxy's root CA is missing from that tool's trust store, or that the tool uses its own CA bundle instead of the operating system's.

How do I fix "unable to get local issuer certificate" in Node.js?

Set NODE_EXTRA_CA_CERTS to a PEM file containing the missing root before starting Node, or run Node with --use-system-ca (or set NODE_USE_SYSTEM_CA=1) so it also trusts the OS store. Do not set NODE_TLS_REJECT_UNAUTHORIZED=0.

Why does pip work but Python requests fails with a certificate error?

pip 24.2 and later use the operating system's trust store through truststore, while requests uses the certifi bundle in your environment. Either use truststore in your application or set REQUESTS_CA_BUNDLE to a bundle that combines certifi's roots with your corporate CA.

What is the difference between "unable to get local issuer certificate" and "self-signed certificate in certificate chain"?

Both mean the chain ends at an untrusted root. With "self-signed certificate in certificate chain", the server or proxy sent the root certificate itself; with "unable to get local issuer certificate", it did not. The fix is the same: trust the correct root.

How do I fix this error in Git on Windows?

Run git config --global http.sslBackend schannel so Git uses the Windows certificate store, which on managed machines already contains the corporate root. Alternatively point http.sslCAInfo at a PEM bundle for the specific host.

Conclusion

"Unable to get local issuer certificate" is a trust-store problem, not a network mystery. Use openssl s_client -showcerts to see who issued the chain, get the verified root from the people who run the proxy or CA, and add it to the store each tool actually reads: NODE_EXTRA_CA_CERTS or --use-system-ca for Node and npm, a combined bundle or truststore for Python, --cacert for curl and http.sslCAInfo for Git. If the chain is incomplete, fix the server instead.