curl on a server fails with curl: (60) SSL certificate problem: unable to get local issuer certificate, and a payment webhook, a monitoring check, or an Android app reports the same failure in its own words. If the certificate is valid and not expired, the cause is usually an incomplete certificate chain on the server. The desktop browser covers for the missing piece without telling you.
This walkthrough goes from that error message to the exact config file you need to change, using openssl s_client to see what the server actually sends.
Why the browser and curl disagree
curl, OpenSSL-based tools, many programming language HTTP libraries, and some mobile clients typically do none of this. They verify using only what the server sent plus their local trust store. With the intermediate missing, the path stops at the leaf and verification fails. The research behind this article, and a Let's Encrypt community thread on exactly this symptom, point to two usual causes: an incomplete chain on the server, or a difference in the client's trust store. The steps below tell you which one you have.
This is a common source of back-and-forth in support tickets. The site owner checks in a browser, sees the padlock, and concludes the problem is on the API provider's side. Asking for one openssl s_client run usually settles it in a few minutes.
Look at what the server actually sends
BASH
# What curl sees, including handshake details (sent to stderr)
curl -sv -o /dev/null https://example.com/
# Every certificate the server sends during the handshake
openssl s_client -connect example.com:443 -servername example.com -showcerts </dev/nulls_client flags do the following:
-servernamesets SNI (Server Name Indication), the hostname the client asks for. On a shared IP, it makes the server pick the right certificate.-showcertsprints every certificate the server sent, not just the leaf.</dev/nullcloses the connection right after the handshake, so the command does not sit waiting for input.
TEXT
Illustrative output format (names are placeholders)
CONNECTED(00000003)
depth=0 CN = example.com
verify error:num=20:unable to get local issuer certificate
verify error:num=21:unable to verify the first certificate
---
Certificate chain
0 s:CN = example.com
i:C = US, O = Example CA, CN = Example Intermediate CA
-----BEGIN CERTIFICATE-----
(base64 data)
-----END CERTIFICATE-----
---
...
Verify return code: 21 (unable to verify the first certificate)Certificate chain section, s: is the subject (who the certificate belongs to) and i: is the issuer (who signed it). Entry 0 is your leaf, and it says it was issued by Example Intermediate CA. The list should continue with an entry 1 whose subject is that intermediate. Here it ends at entry 0, so the server sent one certificate and stopped.
A healthy chain shows at least two entries. The issuer of each entry matches the subject of the next one, and the last line reads Verify return code: 0 (ok). If you only want a quick count, pipe the s_client output into grep -c 'BEGIN CERTIFICATE'. A result of 1 for a CA-issued certificate almost always means the intermediate is missing.
Rule out the look-alikes
curl. The verify code at the bottom of the s_client output tells them apart.
| Verify code | Meaning | Where to look |
|---|---|---|
| 20 or 21 | Client cannot build a path from the leaf to a trusted root | Missing intermediate on the server (this article), or an outdated trust store on the client |
| 10 | Certificate has expired | Renewal process, or a server still serving an old file after renewal |
| 18 or 19 | Self-signed certificate, or a self-signed certificate in the chain | Panel default or placeholder certificate installed instead of the real one |
| 0 (ok), but curl still fails | The server side is fine | Client trust store, a proxy in the path, or a hostname mismatch |
curl reports SSL: no alternative certificate subject name matches target host name, and the subject of entry 0 shows a different domain or the server hostname. That is a certificate selection problem, usually SNI on a shared IP, and it is covered in Wrong SSL Certificate Served on a Shared IP? Test SNI with openssl s_client.
The trust store case matters because the fix is on the other side. If s_client shows a complete chain and Verify return code: 0 (ok) from your machine, but one specific client still fails, that client probably has an old CA bundle. This is typical of an outdated OS, an old language runtime, or a container image that was never updated. Changing your server will not help that client.
Check one more thing if a CDN or reverse proxy sits in front of the site. s_client against the domain shows the proxy's certificate, not your origin's. To test the origin, connect to its IP directly and keep the real hostname for SNI, for example -connect 203.0.113.10:443 -servername example.com (the IP is a placeholder).
Find and fix the file the server uses
s_client confirms the server sends only the leaf, find the certificate file referenced in the web server config. Count the certificates inside it with grep -c 'BEGIN CERTIFICATE' /path/to/file.
- Nginx. Look for
ssl_certificatein the relevantserverblock.nginx -Tprints the full loaded config, which helps when includes are spread over many files. Nginx expects the leaf and the intermediates in that one file. - Apache. Look for
SSLCertificateFile, and on older setupsSSLCertificateChainFile. Since Apache 2.4.8,SSLCertificateFilecan hold the leaf followed by the intermediates, and the separate chain directive is deprecated. On an older Apache, the chain file directive must point to the intermediates.apachectl -Sshows which vhost config handles the domain. - cPanel, LiteSpeed, and other panels. The certificate is usually installed through a form with separate fields for the certificate, the private key, and the CA bundle. A blank or wrong CA bundle field leads to this exact symptom. The field name and location depend on the panel version.
- certbot (Let's Encrypt). The live directory contains
cert.pem(leaf only),chain.pem(intermediates), andfullchain.pem(both). A config pointing atcert.peminstead offullchain.pemis a very common cause.
cat example.com.crt intermediate.crt > fullchain.pem. Write to a new file name rather than overwriting the original, so you can roll back. You usually do not need to include the root, because clients already have it. Order matters: Nginx checks the private key against the first certificate in the file, and a reversed file fails with a key values mismatch error.
For Nginx, the result looks like this:
NGINX
server {
listen 443 ssl;
server_name example.com;
# Leaf first, then intermediate(s). The root is not needed.
ssl_certificate /etc/ssl/example.com/fullchain.pem;
ssl_certificate_key /etc/ssl/example.com/privkey.pem;
}nginx -t for Nginx or apachectl configtest for Apache. Reload only if the test passes. A reload keeps existing connections alive, and a failed config test leaves the running server untouched.
Confirm the fix from the client's side
openssl s_client command again. You should now see entry 0 for your domain and entry 1 for the intermediate, with the issuer of entry 0 matching the subject of entry 1, and Verify return code: 0 (ok) at the end. Then run the curl -sv command from the machine that originally failed. Checking in a browser proves nothing here, because the browser was working all along.
Also check how renewals happen. If an automated renewal rewrites a different path than the one in your config, or a panel reinstalls the certificate without the CA bundle, the error comes back on the next renewal. The config should point at the file the renewal tool keeps up to date with the full chain.
When a browser and curl disagree about a certificate, trust curl. Run openssl s_client -showcerts with the right -servername, count the chain entries, and read the verify code. If the server sends only the leaf, the fix is almost always one file: the one named in ssl_certificate, SSLCertificateFile, or the CA bundle field. It needs the intermediate after the leaf.