Unable to get local issuer certificate: what it means and how to fix it

12 min readUpdated

Unable to get local issuer certificate means a client could not connect the server's certificate to a root authority it trusts [2]. Either the server did not send the intermediate certificate that links the two, or the client's own list of trusted roots lacks the one needed. The message comes from command-line tools and libraries that check certificates with OpenSSL, such as curl, npm, Node.js and Python, not from browsers [1]. That is why a site can open normally in a browser and still fail here; browsers report the same fault under their own codes, collected in SSL errors.

Quick facts

Where it appears
curl, npm and Node.js, Python, and Git when its curl library is built with OpenSSL [1][3][4]
Exact text
unable to get local issuer certificate; in Node.js and npm, the code UNABLE_TO_GET_ISSUER_CERT_LOCALLY [1]
OpenSSL code
verify error 20, X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY [2]
Who fixes it
the server owner if the server omits the intermediate; whoever runs the client if its trust store lacks the root [1]
What does not help
trusting the root on the client while the server omits the intermediate: in our test, curl, Git, Node.js, npm and Python all still failed [1]

What the error means

A server's certificate is signed by an intermediate authority, and the intermediate is signed by a root. The client holds a list of trusted roots, called a trust store or CA bundle, and has to build a path from the server's certificate up to one of them. See certificate chains for how that path works.

"Local issuer" is the next certificate up that path. OpenSSL raises this error when it cannot find the issuer of a certificate it received, neither among the certificates the server sent nor in the local store [2]. The path stops there, and the client refuses the connection.

Where the path stops tells you who has to act. If it stops right after the server's own certificate, the server did not send the intermediate. If it stops after the intermediate, the client lacks the root.

What each tool prints

We reproduced both faults, and a related one, against our test servers [1]:

What each tool prints
ClientServer omits the intermediateClient lacks the rootServer sends an untrusted root
openssl s_client, verify return code21 (unable to verify the first certificate)20 (unable to get local issuer certificate)19 (self-signed certificate in certificate chain)
curl, Pythonunable to get local issuer certificateunable to get local issuer certificateself-signed certificate in certificate chain
Node.js, npmUNABLE_TO_VERIFY_LEAF_SIGNATUREUNABLE_TO_GET_ISSUER_CERT_LOCALLYSELF_SIGNED_CERT_IN_CHAIN

The lines in full

The middle column, as printed:

curl: (60) SSL certificate problem: unable to get local issuer certificate
npm error code UNABLE_TO_GET_ISSUER_CERT_LOCALLY
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1081)
fatal: unable to access 'https://localhost:8442/repo.git/': server certificate verification failed. CAfile: none CRLfile: none

The first line is curl, the second npm, the third the text inside Python's exception, the same for the standard library and for requests, and the fourth Git [1]. Git leaves TLS to the curl library. When curl is built with OpenSSL, it reports SSL certificate problem: followed by OpenSSL's text, and Git prints that after fatal: unable to access '<url>':. When curl is built with GnuTLS, as on our test machine, it writes server certificate verification failed instead, for all three faults, and the words of this page's title never appear [1][3][4].

With UNABLE_TO_VERIFY_LEAF_SIGNATURE, Node.js and npm add a hint to try --use-system-ca, a switch that adds roots; in our test, trusting the root did not help while the intermediate was missing [1].

Server or client: how to tell which

The fault is in one of two places, and one command tells them apart:

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

-showcerts prints the certificates exactly as the server sent them, in its order; it is not a verified chain [2]. Each entry has a subject line s: and an issuer line i:. Here is the server that omits the intermediate, then the one that sends it, from our test [1]:

 0 s:CN = localhost
   i:CN = Lab Test Intermediate
Verify return code: 21 (unable to verify the first certificate)

 0 s:CN = localhost
   i:CN = Lab Test Intermediate
 1 s:CN = Lab Test Intermediate
   i:CN = Lab Test Root
Verify return code: 20 (unable to get local issuer certificate)

Reading the output

  • Only entry 0, and its issuer is an intermediate. The server is missing its intermediate. Every client that does not already hold it fails, and the fix is on the server.

  • The list reaches a certificate issued by a root, and your tool still fails. The client side lacks that root: an outdated bundle, a tool that uses its own bundle instead of the operating system's, or a root of your own organization that was never added.

  • The last entry has the same s: and i:. The server sends a root as well. Error 19, self-signed certificate in certificate chain, means the client does not trust that root [2].

s_client checks against OpenSSL's default store [2], and your tool may use another one. Node.js starts from its own built-in list, and requests from the certifi package [5][7]. A clean Verify return code: 0 (ok) from s_client does not prove that npm or a Python script will connect.

Why the site opens in a browser

Browsers can find a missing intermediate on their own, as the certificate chain page explains. curl does not fetch one: support for the Authority Information Access extension is on its list of work not yet done [3]. So a server that omits its intermediate can pass in a browser and fail in scripts, deployments and package installs.

Fix on the server: send the full chain

Configure the server to send its certificate together with the intermediate in one file. In nginx, ssl_certificate takes that file, with the primary certificate first and the intermediates after it [9]. In Apache 2.4.8 and later, SSLCertificateFile loads intermediates from the same file, sorted from leaf to root [9]. The order, and whether the root belongs in the file, are explained on the certificate chain page.

After a reload, repeat the check above, and entry 1 should appear. In our test, once the server sent the intermediate and the client trusted the test root, s_client returned Verify return code: 0 (ok), and curl, Git, Node.js, npm and Python got through the TLS check [1].

Fix on the client, by tool

When the server sends the full certificate chain, the fix is on the client: its trust store needs the missing root certificate. Get the root in PEM format from the authority that issued it, or, for a root of your own organization, from whoever runs it, and point the tool at that file. The settings for curl, Git, Node.js, npm and Python below come from each tool's documentation. We tried the file-based ones against our test server, and each cleared the error [1].

curl and Git

--cacert /path/to/ca.pem sets the CA bundle for one curl transfer, and the CURL_CA_BUNDLE environment variable sets it for every command [3]. The file takes the place of curl's default bundle, so it has to hold every root certificate the transfer needs. To see which trust store curl uses by default, run curl -v: the verbose output names it in the CAfile: and CApath: lines [3][1].

For Git, git config --global http.sslCAInfo /path/to/ca.pem makes it verify HTTPS remotes against that file, and the GIT_SSL_CAINFO environment variable overrides the setting [4]. On Windows, git config --global http.sslBackend schannel switches Git to the Windows certificate store; with Schannel, Git does not pass the http.sslCAInfo bundle to curl by default [4].

Node.js, npm and Python

Set NODE_EXTRA_CA_CERTS=/path/to/ca.pem before a Node.js process starts. Node.js adds those certificates to its built-in list, reads the variable only at launch, and ignores it when the code passes its own ca option [5]. Since version 23.8, Node.js also accepts --use-system-ca, which trusts the certificates in the operating system's trust store; outside Windows and macOS it works from 23.9 [5].

For npm, npm config set cafile /path/to/ca.pem sets the file it uses for the registry [6]. Like the related ca setting, the file decides which authorities npm trusts, so include every root npm needs [6]. In our test, NODE_EXTRA_CA_CERTS worked for npm as well [1].

In Python, the requests library takes its roots from the certifi package [7]. Point it at another CA bundle with the REQUESTS_CA_BUNDLE environment variable; if that is not set, requests falls back to CURL_CA_BUNDLE [7]. Upgrade certifi with pip install --upgrade certifi; the requests documentation recommends doing so often [7]. The standard library's urllib uses OpenSSL's default paths, and the SSL_CERT_FILE environment variable points them at another file [8][1]. On macOS, python.org builds ship an Install Certificates.command script that installs certifi [8].

Why turning off verification is the wrong fix

Each tool above has a switch that skips the certificate check:

  • curl -k or --insecure. The man page warns that it "makes the transfer insecure", and the curl project asks never to skip verification in production [3].

  • Git http.sslVerify false or GIT_SSL_NO_VERIFY. Git stops verifying the certificate when fetching or pushing over HTTPS [4].

  • Node.js NODE_TLS_REJECT_UNAUTHORIZED=0. The documentation calls the result insecure and the variable "strongly discouraged", and Node.js prints a warning when it is set [5][1].

  • npm strict-ssl false. npm stops validating certificates for registry requests [6].

  • requests verify=False. requests then accepts any certificate, which its documentation says makes the application vulnerable to man-in-the-middle attacks; urllib3 prints InsecureRequestWarning [7][1].

What remains is an encrypted connection to a party nobody checked; for a package install or a deployment, that means accepting code from whoever can intercept it. The server's fault stays in place for every other client. Fix the chain or the trust store instead.

  • self-signed certificate in certificate chain (OpenSSL error 19). The chain could be built from the certificates the server sent, but it does not end at a root in the client's trust store [2]. If that root belongs to your organization, add it as above. If the server itself uses a self-signed root, see self-signed certificates.

  • unable to verify the first certificate (OpenSSL error 21). The chain consists of one certificate that is not self-signed, so no signature could be verified [2]. Node.js and npm report a missing intermediate this way, and the fix is on the server [1].

  • x509: certificate signed by unknown authority. The same fault in programs written in Go [10]. Go's TLS client uses the host's roots unless the program sets its own; SSL_CERT_FILE and SSL_CERT_DIR override where Go looks for them [10].

In browsers, the same fault appears as ERR_CERT_AUTHORITY_INVALID or SEC_ERROR_UNKNOWN_ISSUER [11]. A certificate outside its validity dates is a separate fault, which Chrome reports as ERR_CERT_DATE_INVALID [11].

FAQ

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

The client could not find the certificate that issued one in the server's chain, either among the certificates the server sent or in its own trust store. Without it, the client cannot link the certificate to a trusted root, so it refuses the connection.

How do I fix "unable to get local issuer certificate" in curl?

First check whether the server sends its intermediate with openssl s_client -showcerts. If it does not, the server must be fixed; trusting the root on your side does not help. If it does, give curl the missing root with --cacert /path/to/ca.pem or the CURL_CA_BUNDLE environment variable.

How do I fix it in Git?

Point Git at a bundle containing the missing root with git config --global http.sslCAInfo /path/to/ca.pem. On Windows, setting http.sslBackend to schannel makes Git use the Windows certificate store instead.

How do I fix it in npm or Node.js?

For npm, set the bundle with npm config set cafile /path/to/ca.pem and include every root npm needs. For Node.js applications, set NODE_EXTRA_CA_CERTS to the file's path before the process starts; in our test it fixed npm too.

Why does the site work in my browser but not in curl?

Browsers can find a missing intermediate on their own, so they hide a server that sends an incomplete chain. Curl does not fetch it, so it reports the gap.

Is it safe to disable SSL verification?

No. It removes the check rather than the cause, and leaves the connection open to interception. Add the missing root or fix the server's chain instead.

Sources

  1. Our test: OpenSSL 3.0, curl 8.5, Git 2.43 (curl on GnuTLS), Node.js 25, npm 11, Python 3.14, requests 2.34; test servers with certificates from our own test root.

  2. OpenSSL 3.0 documentation: X509_STORE_CTX_get_error and openssl-s_client; include/openssl/x509_vfy.h.in.

  3. curl: SSL CA Certificates, the man page, the TODO list, and lib/vtls/openssl.c and gtls.c in curl 8.5.0.

  4. Git: git-config documentation and remote-curl.c in Git 2.43.0.

  5. Node.js: Command-line API.

  6. npm: config.

  7. Requests: Advanced usage.

  8. Python documentation: the ssl module and Using Python on macOS.

  9. nginx, ngx_http_ssl_module; Apache HTTP Server 2.4, mod_ssl.

  10. Go: crypto/tls and crypto/x509 documentation, crypto/x509/verify.go.

  11. Chromium, net/base/net_error_list.h; NSS, lib/util/SECerrs.h.