Skip to content

Troubleshooting · Networking, TLS & health checks

TLS certificate expired or not trusted? 6 causes, ranked

6 causes, most common first · last reviewed

TL;DR

First check what the server actually sends, not the file on disk: openssl s_client shows the served certificate's dates and chain. If the leaf has expired, renewal failed or the new certificate was never loaded. If the leaf is valid and only some clients fail, the chain is incomplete or those clients do not trust its root.

On this page

Quick triage: the first five minutes

  1. See the certificate the server really serves for this name: subject, issuer and validity dates.

    Shell
    echo | openssl s_client -connect api.example.com:443 -servername api.example.com 2>/dev/null \
      | openssl x509 -noout -subject -issuer -dates
    notAfter in the past means the served leaf has expired. Always pass -servername so SNI selects the right certificate.
  2. Check the whole chain the server sends, and whether a client can verify it.

    Shell
    echo | openssl s_client -connect api.example.com:443 -servername api.example.com -showcerts 2>/dev/null \
      | grep -E '^ *[0-9] s:|^ *i:|Verify return code'
    'Verify return code: 0 (ok)' is good. Error 20 (unable to get local issuer certificate) usually means a missing intermediate.
  3. Compare with the failing client's error and the date on the client.

    Shell
    curl -sv https://api.example.com/ -o /dev/null 2>&1 | grep -iE 'expire|issuer|verify'
    date -u
    A client clock far off can make a valid certificate look expired or not yet valid.

The causes, ranked

Most common first. The ranking is a judgement from how these failures usually turn out, not a measured statistic.

Most common

1. Renewal failed silently and the certificate expired

What it looks like

  • Every client fails at once: browsers show NET::ERR_CERT_DATE_INVALID, curl says 'certificate has expired', Java reports a CertificateExpiredException inside the handshake error.
  • notAfter on the served certificate is in the past.
  • The renewal job, cron entry or controller has been failing for weeks without anyone noticing.

How to confirm it

Check the renewal tool's own status. With cert-manager on Kubernetes, the Certificate resource reports whether it is ready and why not; the CertificateRequest, Order and Challenge resources show where an ACME renewal got stuck. With certbot, a dry run shows whether renewal would succeed now.

Shell
kubectl get certificate -A
kubectl describe certificate api-tls -n shop
kubectl get certificaterequests,orders,challenges -n shop
Shell
certbot certificates
certbot renew --dry-run

Fix it now

Fix whatever blocked renewal (often DNS or HTTP challenge validation, credentials or rate limits), issue the certificate, then deploy it and confirm with s_client. If renewal cannot be fixed quickly, issue a certificate by hand from the same authority and install it to restore service, then return to the automated path. Remember that clients which cached a failed connection, or pinned the old certificate, may need restarting too.

Prevent it

Monitor the served certificate's expiry from outside, on every hostname, and alert at least two to three weeks ahead, independently of the renewal tool's own alerts.

Most common

2. Renewed, but the old certificate is still being served

What it looks like

  • The certificate file on disk is new, but s_client still shows the old dates.
  • Some endpoints serve the new certificate and others the old one.
  • The certificate lives in several places: load balancer, CDN, ingress, application keystore.

How to confirm it

Compare the expiry of the file with the expiry of what each endpoint serves. Test each node or IP directly, not just the DNS name: behind a load balancer, one node still serving the old certificate fails a fraction of connections, which looks random from the client side.

Shell
openssl x509 -in /etc/ssl/api.example.com/fullchain.pem -noout -enddate
for ip in 10.0.1.10 10.0.1.11; do
  echo | openssl s_client -connect $ip:443 -servername api.example.com 2>/dev/null | openssl x509 -noout -enddate
done

Fix it now

Reload or restart the process that serves TLS (for nginx, a reload picks up new files), and upload the certificate to every load balancer, CDN and keystore that terminates TLS.

Prevent it

Make the renewal process deploy and reload as one step, and keep an inventory of every place each certificate is installed.

Common

3. The server does not send the intermediate certificate

What it looks like

  • Browsers work; curl, Java, Go, Python or mobile apps fail with 'unable to get local issuer certificate' or 'PKIX path building failed'.
  • s_client shows only one certificate in the chain.
  • It started after installing a new certificate file.

How to confirm it

Count the certificates s_client -showcerts prints. Browsers can often fetch a missing intermediate themselves, or have it cached from another site; most other clients cannot. That is why this problem often goes unnoticed until a server-to-server integration or a mobile app starts failing.

Fix it now

Serve the full chain: the leaf followed by its intermediates, usually the provider's fullchain file rather than the leaf-only one. Do not include the root.

Prevent it

Check new certificates with a non-browser client, such as curl or openssl verify, before they go live.

Less common

4. Old clients do not trust the chain's root

What it looks like

  • Only some clients fail: older devices, old operating systems, appliances or partner servers with an old TLS library.
  • The error says the certificate has expired although your leaf is valid; an older root or cross-signed intermediate in the chain is what expired.
  • Up-to-date browsers and phones work fine.

How to confirm it

Check which root the failing client's chain ends in and whether that root is in its trust store. A client can also build a different chain from the same server, depending on its library.

Shell
# on the failing host, with the chain the server sends saved as chain.pem and the leaf as leaf.pem
openssl verify -CAfile /etc/ssl/certs/ca-certificates.crt -untrusted chain.pem leaf.pem
Run it with the failing client's own CA bundle; for Java, check its truststore with keytool -list.

Fix it now

Update the client's CA bundle or Java truststore. If you cannot change the clients, serve a chain they can validate, which may mean a different chain option from your certificate authority.

Prevent it

Keep trust stores updated as part of patching, and know which old clients depend on you before your certificate authority changes roots.

Less common

5. The wrong certificate is served for this name

What it looks like

  • Errors mention the hostname: 'no alternative certificate subject name matches' or a name mismatch.
  • s_client shows a different subject or SAN list from the host you asked for.
  • It happens only for some clients, often those that do not send SNI, or only for a new subdomain.

How to confirm it

Request the certificate with and without -servername and compare. A default certificate returned without SNI points at a missing virtual host or a wildcard that does not cover the name.

Shell
echo | openssl s_client -connect api.example.com:443 -servername api.example.com 2>/dev/null | openssl x509 -noout -ext subjectAltName
echo | openssl s_client -connect api.example.com:443 -noservername 2>/dev/null | openssl x509 -noout -subject

Fix it now

Add the name to the certificate's SANs or configure the virtual host for it, then redeploy.

Prevent it

Test every hostname a service answers to after each certificate change, including new subdomains.

Rare but nasty

6. A clock is wrong

What it looks like

  • One machine or device fails with 'certificate is not yet valid' or 'expired' while others with the same configuration work.
  • The failing host has been powered off for a long time, or its time sync is broken.
  • Logs on that host show timestamps far from real time.

How to confirm it

Compare the host's time with a trusted source and check that time sync is running.

Shell
date -u
timedatectl status | grep -i 'synchronized\|NTP'

Fix it now

Fix time synchronisation and correct the clock, then retry.

Prevent it

Monitor clock offset on every host, and include time sync in the checks for devices that may be offline for long periods.

See it happen in a real outage

90-second puzzles built from public postmortems. Diagnose it first; the company is revealed after you answer.

Related concepts

FAQ

How do I check when an SSL certificate expires from the command line?

Run openssl s_client against the host with -servername, and pipe the result to openssl x509 -noout -dates. notAfter is the expiry. This checks what the server actually serves, which may differ from the file on disk.

Why does it work in the browser but fail in curl or Java?

Usually the server is not sending its intermediate certificate. Browsers can fetch or cache missing intermediates; curl, Java and most libraries cannot, so they cannot build a chain to a trusted root.

What does 'unable to get local issuer certificate' mean?

The client could not find the certificate that issued the one it was given: either the server did not send an intermediate, or the client's trust store does not contain the root at the end of the chain.

The certificate is renewed but clients still see the old one. Why?

The process terminating TLS still has the old certificate loaded, or another endpoint (a load balancer, CDN or another node) still holds it. Reload the server and update every place the certificate is installed.

All troubleshooting guides

Reference documentation: OpenSSL documentation: s_client ↗ · cert-manager documentation: troubleshooting ↗ · RFC 5280: certificate path validation ↗ · Report a problem

Commands and settings are checked against the documentation linked above. Defaults change between versions; check the documentation for the version you run.