ShieldMarc

TLS certificate chain errors: causes and fixes

By ShieldMarcUpdated 9 min read

TLS certificate chain errors mean a client cannot build a trusted path from your server's certificate to a root certificate authority. For example, the server may not be sending its intermediate certificate. This guide gives you the exact openssl commands to confirm it. It also covers four causes to check, the fix for each, and how to verify the fix worked. One mistake to avoid is testing only in Chrome, which quietly repairs some broken chains itself.

Contents
  1. What does a TLS certificate chain error actually mean?
  2. How do you confirm it is a chain error, not something else?
  3. Cause 1: the server is not sending its intermediate certificate
  4. Cause 2: the certificates are in the wrong order
  5. Cause 3: an old or replaced intermediate is still being served
  6. Cause 4: it only fails in some clients, not others
  7. How do you verify the fix worked?
  8. How do you stop it coming back?
  9. Start today
  10. Frequently asked questions

What does a TLS certificate chain error actually mean?

A TLS certificate chain error means the browser or client can't build an unbroken path from the server's certificate to a trusted root certificate authority. That can happen even when the leaf certificate itself is valid and unexpired.

You'll usually spot it from what your browser or client shows:

  • Chrome, NET::ERR_CERT_AUTHORITY_INVALID on its "Your connection is not private" warning page, when it cannot repair the chain itself
  • Firefox, an unknown-issuer warning instead of a padlock
  • Command-line and library clients, such as curl, show unable to get local issuer certificate or unable to verify the first certificate
  • OpenSSL, shows these as error 20 and error 21 (x509_vfy.h header; X509_STORE_CTX_get_error manual)

A publicly trusted chain has at least three certificates: the root, one or more intermediates, and the leaf. The root is self-signed and already trusted by the client. The intermediates sit between that root and the server's certificate, and the server usually supplies them.

This differs from an expired certificate, a hostname mismatch or a self-signed leaf. A chain error means a link is missing or broken between the leaf and a trusted root. The sections below cover common TLS certificate chain errors, with an exact fix for each.

How do you confirm it is a chain error, not something else?

You confirm a chain error by reading the certificates the server sends, not by how a browser displays the site. Run openssl s_client -connect example.com:443 -verify_hostname example.com -showcerts and check the BEGIN CERTIFICATE count and the final Verify return code line (openssl s_client manual).

  • 0 (ok), the chain validated to a trusted root
  • 20, unable to get local issuer certificate, an issuer certificate is missing
  • 21, unable to verify the first certificate, the certificate received cannot chain to anything held

These are OpenSSL's verify error codes (X509_STORE_CTX_get_error manual; x509_vfy.h header).

Leave out -verify_return_error for this check. It stops the handshake at the first error (openssl s_client manual). With that flag, against a TLS 1.2 server, the final line can read Verify return code: 0 (ok) although verification failed.

Chrome or Safari alone can hide the fault by repairing a missing intermediate themselves. So can the curl built into Windows, which relies on Windows certificate checking. Use openssl, or curl on Linux, for a true reading of what your server sends.

Rule out an expired certificate or hostname mismatch first with ShieldMarc's free SSL checker (issuer, SANs, expiry, TLS version). To diagnose a broken SSL certificate chain, use openssl.

Fix a broken certificate chain
  1. Check the chain

    Run openssl s_client -showcerts and read the verify return code.

  2. Get the current bundle

    Download today's certificate and intermediate from your CA, not a cached copy.

  3. Order it correctly

    Put your certificate first, then the intermediate, root last or omitted.

  4. Redeploy and reload

    Point the server at the combined file and reload, not restart, the service.

  5. Verify from outside

    Recheck with openssl or curl, using a client that does not self-repair chains.

Cause 1: the server is not sending its intermediate certificate

This is a common cause of a chain error: a missing intermediate certificate. The server has only its own leaf certificate and never received the one that signed it.

  1. Get the current chain, from the certificate authority's own page or your ACME client's output, not an old saved copy.
  2. Build one file in order: your certificate first, then every certificate in the chain your certificate authority supplies. This file is commonly named fullchain.pem. Keep any cross-signed root in that chain, such as the Root YR certificate in Let's Encrypt's current RSA chains. Clients need that certificate to reach a root they already trust.
  3. Point the server at the right file: use the combined file in nginx's ssl_certificate directive or Apache's SSLCertificateFile (2.4.8+). On older Apache, put the intermediates alone in SSLCertificateChainFile. On a load balancer, fill in its certificate and chain fields.
  4. Reload, not restart, the server, then confirm with the checks later in this guide.

ACME clients such as Certbot (fullchain.pem) and acme.sh (the file named by --fullchain-file) already write the full chain. So point the server at that file rather than the certificate alone.

Cause 2: the certificates are in the wrong order

Here the certificates are present but out of order, usually from a hand-assembled file. RFC 9846 section 4.5.1 (TLS 1.3, replacing RFC 8446) puts your certificate first, then each certificate that signed the one above it. The root may be left out, as TLS 1.2 allowed under RFC 5246 section 7.4.2.

  1. Read every certificate's subject and issuer with openssl crl2pkcs7 -nocrl -certfile file.crt | openssl pkcs7 -print_certs -noout. Use this rather than openssl x509, which reads only the first certificate in a file.
  2. Reorder the file, so each certificate's issuer matches the subject of the one below it.
  3. Rebuild fullchain.pem in that order, and redeploy.

Extra certificates after the leaf are not a fault in themselves. RFC 9846 says clients SHOULD cope with them, and with any order after the leaf. So a misordered chain breaks only clients that don't.

A cross-signed intermediate during a root transition isn't a fault either. Either valid cross-sign can sit second (Let's Encrypt: certificates).

Pro Tip: When you rebuild fullchain.pem, list every certificate inside it with openssl crl2pkcs7 -nocrl -certfile fullchain.pem | openssl pkcs7 -print_certs -noout before you deploy. Don't use openssl x509 for this, because it reads only the first one. The issuer of each entry must exactly match the subject of the entry below it. If it doesn't, the reorder hasn't actually fixed anything.

Cause 3: an old or replaced intermediate is still being served

Certificate authorities rotate or retire intermediates. A server serving last renewal's bundle breaks, even though its leaf certificate is fine. Occasionally an intermediate expires or is revoked.

  1. Check the intermediate's dates, with openssl x509 -in intermediate.crt -noout -dates.
  2. Fetch the current chain, from the certificate authority's own page, not a cached file.
  3. Rebuild fullchain.pem and redeploy, to every server or load balancer node using it.
  4. Check your renewal automation, that it re-fetches the chain each run and is still running, not silently failing.

Cause 4: it only fails in some clients, not others

A broken chain can load in one client and fail in another, because several clients repair a missing intermediate themselves.

Treat "it loads fine in Chrome" as no evidence the chain is fixed. Serve the complete chain yourself so curl, Java and mobile apps work too.

Who patches a broken chain?

Self-repairs

  • Chrome: fetches via AIA, not on iOS
  • Safari/iOS: Apple's verifier fetches it
  • Firefox: preloads common intermediates

Needs full chain

  • curl: no built-in AIA support
  • Java: AIA off by default
  • Android apps: no automatic repair

How do you verify the fix worked?

You verify the fix by re-running openssl s_client without -verify_return_error. Check for Verification: OK and Verify return code: 0 (ok), with each certificate's issuer matching the subject below it.

Test the live server with a client that doesn't self-repair a chain, such as curl -v https://example.com on Linux. Don't use the curl built into Windows. It relies on Windows certificate checking, so it can fetch a missing intermediate itself.

openssl verify -CAfile ca-bundle.pem -untrusted chain.pem yourcert.pem checks only your local files before you deploy. It needs the intermediates passed with -untrusted, because openssl verify reads only the first certificate in a file (openssl verify manual).

Check from more than one edge location where a CDN is involved. ShieldMarc's free SSL checker then confirms the issuer, SANs, expiry and TLS version. Its answer may be up to about an hour old, so use openssl when you need a result right after a change.

How do you stop it coming back?

You stop a chain error coming back by making the fix part of your deploy pipeline, not a one-off manual rebuild. Build fullchain.pem from the certificate authority's current chain file as a pipeline step, so every renewal assembles it the same way.

Publicly trusted certificates are now capped at 200 days' validity. The cap falls to 100 days from 15 March 2027 and 47 days from 15 March 2029 (CA/Browser Forum Ballot SC081v3).

That means renewals, and the chance to reintroduce a mistake, come round far more often. Watch the certificate authority's own notices for root or intermediate changes.

Monitor continuously rather than waiting for a customer report. ShieldMarc's SSL monitor checks port 443 daily and alerts you when a certificate is expired, invalid, or within 7 days of expiring. When it flags one, use this guide's commands to find out why, alongside ShieldMarc's guide to SSL certificate monitoring.

For UK public sector readers, NCSC guidance recommends that government systems stop supporting TLS 1.0 and 1.1, deprecated by RFC 8996. It also recommends upgrading them to support TLS 1.3. Fixing the chain is a good moment to check this too.

Start today

Run the openssl s_client command against your own domain. ShieldMarc's free SSL checker adds a quick read of issuer, SANs, expiry and TLS version with nothing to install.

If the chain is broken, rebuild fullchain.pem in the correct order from the certificate authority's current files, and redeploy. That fixes a missing, misordered or outdated intermediate (causes 1 to 3 above).

Add ongoing monitoring so the next renewal failure is caught before a customer reports it. ShieldMarc's Professional plan costs £70 a month, or £50 a month billed annually, and covers SSL monitoring across 25 domains. Every sign-up starts with a 30-day trial, no card required.

For a mail server, check the SMTP chain with openssl s_client -connect mail.example.com:25 -verify_hostname mail.example.com -starttls smtp -showcerts. The certificate only arrives after the STARTTLS command. For the wider picture, ShieldMarc's free Security Grade check covers DNS, DMARC and your web certificate together as one A+ to F grade.

Frequently asked questions

Does a certificate chain error mean my certificate is invalid?

No: the leaf certificate can be valid and unexpired when this error appears. The fault is a broken link to a trusted root, from an intermediate that is missing, wrong, or out of order. So check expiry and chain completeness separately.

Why does the site work in Chrome but fail in curl or a mobile app?

Chrome's verifier, and Apple's, can fetch or already hold a missing intermediate, masking a broken chain. Others don't, such as curl on Linux, many Java services and Android apps. So serve the complete chain yourself rather than rely on any client to patch it.

Do I need to include the root certificate in the chain?

No: clients already hold the root in their own trust store, so it's normally left out. The order needed is your certificate, then the intermediate or intermediates, including any cross-signed root the certificate authority supplies. Sending the self-signed root too is simply unnecessary, not broken.

Does this affect email delivery too?

Sometimes: a mail server's STARTTLS certificate can have the same fault. Opportunistic TLS between mail servers generally delivers past an untrusted certificate, but a sender enforcing your MTA-STS policy must not deliver to it. To check a mail server's certificate, run openssl s_client -connect mail.example.com:25 -verify_hostname mail.example.com -starttls smtp -showcerts.

For Postfix, the order is server certificate first, then issuing CAs bottom-up. The root is optional unless DANE-TA (2 x x) TLSA records reference it (Postfix TLS README). For mail TLS, see how MTA-STS and TLS-RPT work on the MTA-STS Checker.

How often should I recheck the certificate chain?

Recheck after every renewal, not just at initial setup, since intermediates rotate and automation can fail silently. Maximum certificate lifetimes are now down to 200 days. They fall to 100 days from 15 March 2027 and 47 days from 15 March 2029 (CA/Browser Forum Ballot SC081v3). So renewals come round more often, and continuous monitoring catches a broken renewal in between.

Sources