Back to blog
Linux & Servers Published November 23, 2026

Fix: SSL certificate problem: unable to get local issuer certificate

Automate WhatsApp Alerts
Start Free ➔
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.se/docs/sslcerts.html

The same problem shows up under other names: unable to verify the first certificate (Node.js), SSL: CERTIFICATE_VERIFY_FAILED (Python), x509: certificate signed by unknown authority (Go), server certificate verification failed (git).

Quick fix: decide whose fault it is first, because the fix is on a different machine in each case.

  • If it fails for everyone and from several machines: the server isn't sending its full certificate chain. Install fullchain.pem, not just the certificate (section 2).
  • If it fails on one machine or one network only: that client doesn't trust the issuer, often because of an old CA bundle or a company proxy (section 3).

Don't "fix" it with curl -k, verify=False or NODE_TLS_REJECT_UNAUTHORIZED=0. That switches certificate checking off, so anyone on the network path can impersonate the server.


1. Find out which side is broken

Run this against the failing host:

openssl s_client -connect example.com:443 -servername example.com -showcerts </dev/null 2>/dev/null | grep -E "^ *[0-9]+ s:|Verify return code"

Read the result:

  • Only one certificate is listed (depth 0) and the last line says Verify return code: 21 (unable to verify the first certificate) or 20 (unable to get local issuer certificate): the server sent only its own certificate and left out the intermediate. This is a server problem.
  • Two or three certificates are listed and the result is 0 (ok) from here, but one other machine fails: that machine is the problem (section 3).

An online tool gives the same answer: the free SSL inspector shows the certificate chain the server really sends.

Why it works in a browser but not in curl

This is the most confusing part. Browsers can download a missing intermediate certificate on their own, using the AIA field in the certificate. curl, Python, Node.js and most other tools don't. So a site with an incomplete chain can look fine in Chrome while every script and API client fails.


2. Server side: send the full chain

A certificate authority signs your certificate with an intermediate certificate. Clients trust the root, so the server must send the intermediate along with its own certificate.

With Let's Encrypt and certbot, use fullchain.pem (certificate plus intermediate), not cert.pem:

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

Apache 2.4.8 and later takes the chain from the same file:

SSLCertificateFile    /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem

(Older Apache needs the intermediate in a separate SSLCertificateChainFile.)

For a certificate bought from another CA, build the chain yourself: your certificate first, then the intermediate(s), in that order, in one file:

cat your_domain.crt intermediate.crt > fullchain.crt

Then test the config and reload:

sudo nginx -t && sudo systemctl reload nginx
# Apache: sudo apachectl configtest && sudo systemctl reload apache2

Run the openssl s_client command from section 1 again. You should now see two certificates and Verify return code: 0 (ok). If the order in the file is wrong or the key doesn't match the certificate, see certificate and private key mismatch.

Don't forget other places that serve TLS on the same domain: a load balancer, a CDN origin, a mail server or a database proxy can each have their own certificate file.


3. Client side: the machine doesn't trust the issuer

If the server's chain is complete and only some machines fail, check the client.

  • Old or missing CA bundle. Update it. Debian and Ubuntu: sudo apt update && sudo apt install --reinstall ca-certificates && sudo update-ca-certificates. Alpine and minimal Docker images often have no CA bundle at all: apk add ca-certificates or apt install ca-certificates.
  • Company proxy that re-signs HTTPS. The proxy replaces the server certificate with one signed by your company's CA. Install that CA on the machine, or point the tool at it.
  • A self-signed or private CA certificate. Give the tool the CA certificate instead of disabling checks.
  • Wrong system clock. A clock years in the past or future makes valid certificates look not yet valid or expired.

Pointing common tools at an extra CA file:

curl --cacert /path/to/ca.pem https://internal.example.com/
export NODE_EXTRA_CA_CERTS=/path/to/ca.pem           # Node.js
export REQUESTS_CA_BUNDLE=/path/to/ca.pem            # Python requests
git config --global http.sslCAInfo /path/to/ca.pem   # git

4. Errors that look similar

MessageMeaningGuide
unable to get local issuer certificateChain can't be built to a trusted rootThis page
certificate has expiredCertificate is past its end dateRenew it, see section 5
certificate is not valid for <name> / hostname mismatchCertificate is for a different domainReissue including the right names
key values mismatchCertificate and private key don't belong togetherMismatch guide
SSL_ERROR_RX_RECORD_TOO_LONGHTTPS is being spoken to a plain HTTP portRX record guide

5. Know before it breaks for your users

A missing intermediate certificate often appears right after a certificate renewal or a server move, and browsers hide it, so you won't notice until an API client, a webhook sender or a mobile app starts failing.

  • An HTTP monitor on your HTTPS URL from outside your network fails when the TLS handshake can't complete or the certificate is invalid.
  • SSL expiry tracking warns you before a certificate runs out.

Pingzo does both: HTTP checks every 1 to 15 minutes depending on your plan, and on paid plans a daily SSL expiry check with alerts at 30, 14, 7 and 1 days before expiry, sent to WhatsApp, Slack, Telegram, Discord or email. More on the approach in automated SSL certificate expiry monitoring.


Summary checklist

  1. Run openssl s_client -connect host:443 -servername host -showcerts and read Verify return code.
  2. One certificate only, code 20 or 21: switch the server to fullchain.pem and reload.
  3. Full chain but one client fails: update that machine's CA bundle or add the missing CA.
  4. Re-test from a second network and from a script, not only from a browser.
  5. Never ship verify=False or -k as the fix.

Related guides

Zero-Code Uptime Alerts

Stop Finding Out About Outages from Angry Users

Get instant WhatsApp & Discord alerts the second your API, website, or server goes down. Setup in 30 seconds, with checks as often as every minute.

WhatsApp & Discord 60-Second Checks Free Forever Plan
Try Pingzo Free

Know before your users do

Connect official WhatsApp notification channels, Discord webhooks, Telegram bots, and public status pages. Start in 30 seconds.

Create Free Monitor