The same server, the same certificate, the same private key: one test failed with unable to get local issuer certificate and the other answered with HTTP 200. The only difference was a 631-byte file that one server sent and the other did not. That file was an intermediate certificate, and leaving it out is one of the most common TLS mistakes in home labs and small business servers. It is also one of the hardest to notice, because desktop browsers often paper over it while command-line tools and scripts refuse to connect. A test chain built with OpenSSL 3.0.13 shows exactly where it breaks.
Three certificates, one chain
Root, intermediate, leaf
A website’s certificate is rarely signed directly by a certificate authority’s root. The usual chain has three links. The root certificate is self-signed and sits in the trust store of the operating system or browser. The root signs an intermediate certificate. The intermediate signs the server’s own certificate, often called the leaf, which names the website.
For the test, OpenSSL built a private version of that structure: a “Home Lab Root CA,” a “Home Lab Intermediate CA” signed by the root, and a leaf for the made-up name nas.home.test signed by the intermediate. Checking each with openssl x509 -noout -subject -issuer showed the links:
| Certificate | Subject | Issuer |
|---|---|---|
| Root | Home Lab Root CA | Home Lab Root CA |
| Intermediate | Home Lab Intermediate CA | Home Lab Root CA |
| Leaf | nas.home.test | Home Lab Intermediate CA |
Why the middle link exists
Keeping the root’s private key offline and doing day-to-day signing with an intermediate limits the damage if a signing key leaks. The intermediate can be revoked and replaced without changing the root that devices already trust.

How a client checks the chain
Walking up to a trusted root
A client receiving the leaf looks at its issuer, finds the certificate for that issuer, checks the signature, and repeats until it reaches a root it already trusts. If any link is missing, the walk stops.
The test reproduced that directly. With only the root marked as trusted, openssl verify -CAfile root.pem leaf.pem failed with error 20 at 0 depth lookup: unable to get local issuer certificate. The client knew the root, but it had no way to get from the leaf to the root, because the intermediate was not in hand. Adding -untrusted int.pem, which supplies the intermediate as a stepping stone without trusting it on its own, returned leaf.pem: OK.
Who is supposed to send the intermediate
The server is. The TLS 1.3 specification, RFC 8446, says in section 4.4.2 that “The sender’s certificate MUST come in the first CertificateEntry in the list,” and that each certificate after it should directly certify the one before. The root itself can be left out: a certificate that specifies a trust anchor “MAY be omitted from the chain” when peers are known to have it already.
The experiment: two servers, one difference
Setup
Two openssl s_server instances ran side by side with the same leaf and key. The first, on port 8443, sent only the leaf. The second, on port 8444, added -cert_chain int.pem so it sent the intermediate too. Each was then tested by three clients, all trusting only the home lab root.
The results
| Client | Leaf only (8443) | Leaf + intermediate (8444) |
|---|---|---|
openssl s_client |
Verify return code: 21 (unable to verify the first certificate) | Verify return code: 0 (ok) |
| curl 8.5.0 | curl: (60) SSL certificate problem: unable to get local issuer certificate |
HTTP 200 |
Python 3.13 ssl module |
Failed: unable to get local issuer certificate | Connected over TLSv1.3 |
s_client also printed the chain each server sent. Port 8443 showed a single entry, 0 s:CN = nas.home.test, issued by the intermediate the client had never seen. Port 8444 showed two entries, the leaf and then the intermediate issued by the root.
Sending too much is harmless
A third server sent the leaf, the intermediate and the root. s_client listed all three and still returned Verify return code: 0 (ok). RFC 8446 asks implementations to tolerate this: “all implementations SHOULD be prepared to handle potentially extraneous certificates and arbitrary orderings.” Including the root wastes a few hundred bytes per handshake but breaks nothing. Leaving out the intermediate breaks everything that cannot find it on its own.

Why the browser said it was fine
Browsers remember intermediates
This is where the mistake hides. The nginx guide to configuring HTTPS servers explains it: “Browsers usually store intermediate certificates which they receive and which are signed by trusted authorities, so actively used browsers may already have the required intermediate certificates and may not complain about a certificate sent without a chained bundle.” A browser that visited any other site using the same intermediate already has it cached.
Firefox preloads them
Firefox goes further. Mozilla’s security blog post on preloading intermediate CA certificates describes how Firefox downloads the intermediates that certificate authorities disclose, so users “avoid seeing an error page for one of the most common server configuration problems: not specifying proper intermediate CA certificates.”
That is good for people browsing. It is bad for the person who set up the server, tested it in a desktop browser, saw a padlock and moved on. curl, Python scripts, monitoring tools and API clients do not share a browser’s cache, and they fail the way the test clients did.
When the client is the problem
Private roots need to be trusted on purpose
In a home lab, a missing intermediate is only half the story. A certificate from a private certificate authority, like the test’s “Home Lab Root CA,” is not trusted anywhere until someone says so. Connecting to the correctly configured port 8444 without pointing the client at the root gave Verify return code: 20 (unable to get local issuer certificate) from s_client and the same curl: (60) error as before. The chain was complete; the client simply had no reason to trust its top.
The error text is identical to the missing-intermediate case, which is why the two problems are so often confused. The s_client chain listing tells them apart: if the server sends the intermediate and the error persists, the root is what the client lacks.
Three ways to fix it per tool
curl accepts the root directly. Its manual page describes --cacert as “Use the specified certificate file to verify the peer,” and adds that curl also reads a CURL_CA_BUNDLE environment variable, with --cacert taking precedence.
Python’s ssl module takes a cafile argument to create_default_context(), which the ssl documentation describes as “optional CA certificates to trust for certificate verification.” For code that cannot be changed, ssl.get_default_verify_paths() on the test machine reported openssl_cafile_env='SSL_CERT_FILE', and setting SSL_CERT_FILE=root.pem before running an unmodified script let it connect over TLSv1.3.
The cleaner long-term fix is adding the home lab root to the operating system’s trust store, so every program on the machine picks it up at once.

Fixing it on the server
Concatenate in the right order
For nginx, the fix is a combined file. The nginx guide says the authority’s bundle “should be concatenated to the signed server certificate” and that “The server certificate must appear before the chained certificates in the combined file”:
cat www.example.com.crt bundle.crt > www.example.com.chained.crt
The ssl_certificate directive then points at the chained file. The guide warns that if the order is wrong, nginx refuses to start with a “key values mismatch” error, because it checks the private key against the first certificate in the file.
ACME clients usually do this already
Tools that request certificates automatically through the ACME protocol typically write both a leaf-only file and a full-chain file. The most common version of this mistake is pointing the server at the leaf-only file. When a certificate renewal suddenly breaks command-line clients but not browsers, the file path in the server configuration is the first thing to check.
Testing a chain before anyone else does
The one-line check
The nginx guide recommends openssl s_client for exactly this, noting that “If a certificate bundle has not been added, only the server certificate #0 will be shown.” In practice:
openssl s_client -connect example.com:443 -servername example.com </dev/null
Look at the “Certificate chain” block. A healthy public site shows at least two entries, numbered 0 and 1. A single entry 0 whose issuer is an intermediate means the chain is incomplete. The Verify return code line at the end confirms it: 0 is good, while 21, “unable to verify the first certificate,” is the classic missing-intermediate result.
A habit worth keeping
After any certificate change, test with a client that has no memory, such as curl or openssl s_client, rather than a browser that has been visiting sites all week. The browser is the most forgiving client the server will ever meet; the scripts and devices that talk to it at three in the morning are the least.
Sources
- IETF, RFC 8446, “The Transport Layer Security (TLS) Protocol Version 1.3”, Section 4.4.2: https://www.rfc-editor.org/rfc/rfc8446.html
- nginx documentation, “Configuring HTTPS servers”: https://nginx.org/en/docs/http/configuring_https_servers.html
- curl manual page: https://curl.se/docs/manpage.html
- Python documentation, “ssl — TLS/SSL wrapper for socket objects”: https://docs.python.org/3/library/ssl.html
- Mozilla Security Blog, “Preloading Intermediate CA Certificates into Firefox” (November 13, 2020): https://blog.mozilla.org/security/2020/11/13/preloading-intermediate-ca-certificates-into-firefox/
