The symptom and its three causes#
OpenSSL reports X509_V_ERR_CERT_HAS_EXPIRED with the text certificate has expired when a certificate's notAfter date is before the current time. Clients built on OpenSSL pass that string through: curl prints SSL certificate problem: certificate has expired, Python raises SSLCertVerificationError with that text in its verify_message, and Node.js reports the code CERT_HAS_EXPIRED. Go folds both date failures into one message, x509: certificate has expired or is not yet valid, followed by the current time and the date it was compared with. OpenSSL verify error codes · curl OpenSSL backend · Python ssl exceptions · Node.js TLS error codes · Go x509 verify
The error does not say which certificate expired. Three cases are common:
- The leaf expired. The dependency's own certificate passed its notAfter date, usually because renewal failed or the renewed certificate was never deployed to every endpoint.
- An intermediate expired. The server still sends an old intermediate in its chain after the CA issued a new one. The leaf is current; the chain file next to it is not.
- A cross-signed path expired. A root can be cross-signed by an older root so that old clients trust it. When the older root or the cross-signature expires, a client that still builds its path through it fails, while a client that knows the newer root succeeds. Let's Encrypt's DST Root CA X3 cross-signature expired on 30 September 2021, and Let's Encrypt noted that OpenSSL 1.0.x clients failed on the recommended chain even when they trusted ISRG Root X1. DST Root CA X3 expiration
A fourth case looks the same from the error text: the client's clock is wrong. If your clock runs ahead, a current certificate looks expired. That case has its own guide: certificate is not yet valid and clock skew.
Why they look alike#
A TLS 1.3 server sends its own certificate first, and each following certificate should be the issuer of the one before it. A certificate that is a trust anchor may be left out. The client then builds a path from the leaf to a root in its own trust store, using the certificates the server sent and anything in its store. Two clients can build different paths from the same server response, so one fails and the other connects. RFC 8446 Certificate message · OpenSSL path building
The validity period of a certificate runs from notBefore through notAfter, inclusive, and every certificate in the path is checked against the current time. RFC 5280 validity
Print every certificate the server sends#
Run this from the host or container that fails, so you use the same network path and, ideally, the same OpenSSL build. -showcerts prints the list as the server sent it, in order; it is not a verified chain. -servername sets SNI to the name your client uses. openssl s_client
openssl s_client -connect orders.example.com:443 -servername orders.example.com \
-showcerts </dev/null 2>/dev/null \
| awk '/BEGIN CERTIFICATE/{n++; p=1} p{print > ("chain-" n ".pem")} /END CERTIFICATE/{p=0}'
for f in chain-*.pem; do
echo "== $f"
openssl x509 -in "$f" -noout -subject -issuer -dates
done
chain-1.pem is the leaf. -dates prints notBefore and notAfter. The awk step writes files to the current directory, so run it in a scratch directory. openssl x509
Then read what your client concluded. Without -verify_return_error, s_client continues after verify errors and prints each one, so you see the depth that failed:
openssl s_client -connect orders.example.com:443 -servername orders.example.com \
</dev/null 2>&1 | grep -E 'depth=|verify error|Verify return code'
depth=0 is the leaf. A verify error:num=10:certificate has expired line after depth=1 points at an intermediate, and one after the deepest depth points at the root or cross-sign your client chose. For a database that starts TLS inside its own protocol, add -starttls postgres or -starttls mysql. s_client -starttls
curl gives a shorter view of the leaf. curl -v prints the server certificate's subject, start date, expire date and issuer before the request. curl OpenSSL backend
curl -v -o /dev/null https://orders.example.com/ 2>&1 | grep -E 'subject:|start date:|expire date:|issuer:|SSL certificate problem'
Read the result#
| What you see | Points to | Who fixes it |
|---|---|---|
| Leaf notAfter in the past | Leaf expired | Dependency owner renews and redeploys |
| Leaf current, a sent intermediate expired | Stale chain file | Dependency owner replaces the chain |
| All sent certificates current, error at the deepest depth | Expired cross-sign or old root in your path | You update the client's trust store or library |
| All current, and the dates are within your clock's offset | Clock skew | Fix the client's time source |
| Works from your laptop, fails from the service | Different trust store or library | Compare stores: container CA bundle |
If a different client on the same network connects without error, compare OpenSSL versions and trust stores before blaming the server.
A worked example with two outcomes#
This example is illustrative. The checkout service in account 111122223333 starts failing calls to payments.example.com at 00:00 UTC with certificate has expired.
In the first outcome, the chain printout shows:
| Certificate | notAfter |
|---|---|
| chain-1 (payments.example.com) | 22 Nov 2026 23:59 UTC |
| chain-2 (Example Issuing CA) | 2029 |
The leaf expired at midnight. Every client fails, browsers included. The payments team's renewal job had failed silently; nothing in checkout needs to change.
In the second outcome, chain-1 and chain-2 are current, but the server also sends chain-3, a cross-signed copy of Example Root R2 signed by Example Root R1, whose notAfter passed. orders, running a newer base image, connects; checkout, on an image with OpenSSL 1.0.2, fails at depth 3: the old library builds its path through the expired cross-sign even though Example Root R2 is in its store, the failure Let's Encrypt described for OpenSSL 1.0.x. Updating the checkout image or its library fixes it; the payments team can also stop sending the cross-sign.
Limits#
s_client shows what the server sends and what this OpenSSL build concludes. Your service may use another library (Go, Java, a statically linked OpenSSL) with its own trust store and path building, so a clean s_client run does not clear the service. Behind a load balancer or CDN, different nodes can serve different chains; repeat the check a few times or against each address the name resolves to.
Certificates are checked during the handshake, so a client that holds open connections keeps working until it reconnects. That can hide an expired leaf until a deploy or a connection reset forces new handshakes. If an expired certificate is one of several dependency failures, the hub for runtime dependency failures lists the other layers to rule out, and the chain and local issuer guide covers a chain that is incomplete rather than expired.
Questions#
Why does the browser accept the certificate when my service rejects it as expired?
The browser and your service use different libraries and trust stores, and each builds its own path from the certificates the server sends. A service on an old base image or old OpenSSL can follow a cross-signed path to an expired root, as with the DST Root CA X3 cross-sign. Compare the depth that fails in s_client with the certificates the server sends.
Does a renewed certificate fix clients immediately?
New connections see it as soon as every endpoint serves it. Endpoints behind a load balancer or CDN can switch at different times, so repeat the chain printout against each address until all of them serve the new certificate.
How do I check expiry ahead of time without connecting from production?
Run openssl x509 -noout -enddate or -checkend with a number of seconds on each certificate in the chain; -checkend exits nonzero if the certificate expires within that window. openssl x509 -checkend