Skip to content

Diagnosing intermittent TLS handshake errors

Intermittent TLS handshake failures are rarely the cert. Here is how to narrow down the actual cause from logs, packet captures, and openssl.

A small fraction of users — typically the ones least likely to file a useful ticket — see a browser warning that the connection failed before the page loaded. The handshake works for you, works for the monitoring probe, works for 99% of users. The 1% is real and it’s almost never the certificate itself. Intermittent handshake failures live in the layer between client and server: SNI mismatches, MTU on a specific carrier, an OCSP responder that returns slowly, a load balancer node serving a stale cert.

What’s happening

A TLS handshake involves the client and server agreeing on a cipher, exchanging certificates, and validating the chain. Intermittent failures usually trace to one of:

  • SNI mismatch: one origin in a pool was deployed with the wrong cert, so requests round-robin into a working cert most of the time and a broken cert occasionally.
  • MTU/PMTU: the certificate chain plus extensions exceeds the path MTU for some carriers, the IP fragmentation needed is being dropped by an intermediate device, and the handshake stalls.
  • OCSP stapling: the server is trying to fetch a fresh OCSP response and the responder is slow or returning errors; clients with hard-fail OCSP settings drop the connection.
  • TLS version or cipher: an older client speaks TLS 1.0 or a cipher the server has disabled, and the handshake aborts before any application data flows.
  • Time skew: a client with a wildly wrong clock sees notBefore or notAfter as invalid.

How to verify

Pin to a single backend and confirm the cert is consistent across the pool:

for ip in $(dig +short example.com); do
  echo "=== $ip ==="
  openssl s_client -connect "$ip":443 -servername example.com </dev/null 2>/dev/null \
    | openssl x509 -noout -subject -dates -fingerprint
done

If fingerprints differ across pool members, that is the bug.

Check what cipher and TLS version a problem client negotiates:

openssl s_client -connect example.com:443 -servername example.com -tls1_2 </dev/null
openssl s_client -connect example.com:443 -servername example.com -tls1_3 </dev/null

Check OCSP stapling and chain delivery:

openssl s_client -connect example.com:443 -servername example.com -status </dev/null 2>&1 \
  | grep -E 'OCSP|verify return|Server certificate'

In the server log, look for handshake-level errors:

grep -iE 'ssl_handshake|handshake failed|alert' /var/log/nginx/error.log | tail -50

Patterns: same client IP repeatedly failing, same carrier ASN, same time window — each narrows the cause.

The fix

  1. If certs differ across the pool, redeploy the correct cert and reload every node. Bake the cert fingerprint check into the post-deploy verification, not into a separate audit.
  2. If OCSP responder latency is the issue, enable OCSP stapling at the web server and set a long stapling cache (ssl_stapling_responder_timeout 5s in nginx, with a fresh response refreshed in the background). Don’t disable stapling — that just shifts the problem to the client.
  3. If chain plus extensions exceeds 1500 bytes, switch to a shorter chain (modern CAs offer alternate chains) or to ECDSA keys, which produce smaller certs and reduce the chance of fragmentation.
  4. Set a sensible TLS floor — TLS 1.2+ — and drop the ciphers no modern client needs. The handful of users on truly ancient devices will see a clean error message instead of a stall.

Intermittent handshake errors get fixed when you stop treating them as “TLS is flaky” and start treating them as a specific failure mode with a specific signature.


Stack Harbor owns TLS configuration and observability as part of Monitoring & Support. If you’ve got a stubborn handshake bug, book a session.