Insights

Browser Shows the Padlock but curl Fails? Check the Chain with openssl s_client

December 1, 2026
0:00
Your site shows a padlock in Chrome on your laptop. Then 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.
A public TLS certificate usually comes in a chain. Your site's certificate is called the leaf. An intermediate certificate from the certificate authority (CA) signs the leaf, and a root certificate signs the intermediate. Operating systems and browsers ship with a list of trusted roots, called the trust store. They do not ship with every intermediate. During the TLS handshake, the server is expected to send the leaf plus any intermediates, so the client can build a path from your certificate up to a root it already trusts. If the server sends only the leaf, the client has to find the intermediate some other way. Desktop browsers are good at this. They may already have the intermediate cached from another site signed by the same CA. They can download it from the URL embedded in the certificate's Authority Information Access (AIA) field. Firefox also keeps its own list of known intermediates. So the padlock appears and nothing looks wrong. 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.
Run these from a machine outside the server if you can. A second machine also helps you rule out a broken trust store on one client.
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/null
The s_client flags do the following:
  • -servername sets SNI (Server Name Indication), the hostname the client asks for. On a shared IP, it makes the server pick the right certificate.
  • -showcerts prints every certificate the server sent, not just the leaf.
  • </dev/null closes the connection right after the handshake, so the command does not sit waiting for input.
For an incomplete chain, the output looks roughly like this. The exact layout differs between OpenSSL versions.
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)
In the 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.
Several other problems also produce certificate errors in curl. The verify code at the bottom of the s_client output tells them apart.
Verify codeMeaningWhere to look
20 or 21Client cannot build a path from the leaf to a trusted rootMissing intermediate on the server (this article), or an outdated trust store on the client
10Certificate has expiredRenewal process, or a server still serving an old file after renewal
18 or 19Self-signed certificate, or a self-signed certificate in the chainPanel default or placeholder certificate installed instead of the real one
0 (ok), but curl still failsThe server side is fineClient trust store, a proxy in the path, or a hostname mismatch
A hostname mismatch looks different. 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).
Once 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_certificate in the relevant server block. nginx -T prints 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 setups SSLCertificateChainFile. Since Apache 2.4.8, SSLCertificateFile can 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 -S shows 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), and fullchain.pem (both). A config pointing at cert.pem instead of fullchain.pem is a very common cause.
If your CA gave you the leaf and the intermediate as separate files, build a new combined file with the leaf first and the intermediates after it, for example 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;
}
Test the config before reloading, using 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.
Run the same 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.

Join My Newsletter & Get Updates!

Get notified whenever a new technical guide, server infrastructure breakdown, or personal reflection goes live, plus a curated weekly digest.