DEV Community

Deep Fix
Deep Fix

Posted on

SSL/TLS Handshake Failure: Complete Guide for Developers & DevOps

Introduction

SSL/TLS handshake failures can bring your services to a halt. This guide walks developers, engineers, and DevOps professionals through the most common reasons and provides concrete, repeatable fixes.

Common Causes

  • Expired or self‑signed certificates
  • Incomplete certificate chain
  • Hostname mismatch
  • Out‑of‑date trust store or protocol version
  • Cipher suite incompatibility

Step‑by‑Step Troubleshooting

  1. Inspect the server certificate chain
   openssl s_client -connect example.com:443 -servername example.com -showcerts
Enter fullscreen mode Exit fullscreen mode

Look for Verify return code: 0 (ok). Any error lines indicate missing intermediate certificates.

  1. Validate hostname matching
   echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -subject
Enter fullscreen mode Exit fullscreen mode

Ensure the CN or SAN entries contain example.com.

  1. Update the client trust store
   sudo update-ca-certificates   # Debian/Ubuntu
   sudo update-ca-trust force-enable && sudo update-ca-trust extract   # RHEL/CentOS
Enter fullscreen mode Exit fullscreen mode
  1. Force a compatible TLS version (useful for legacy servers)
   curl --tlsv1.2 https://example.com
Enter fullscreen mode Exit fullscreen mode
  1. Check cipher suite compatibility
   openssl ciphers -v 'ALL:@SECLEVEL=1'
Enter fullscreen mode Exit fullscreen mode

Automate the Fix with a Pre‑configured Script

You can run a ready‑made script that applies the above checks and patches common mis‑configurations. Download the pre‑configured script here.

Additional Resources

Conclusion

By systematically verifying the certificate chain, hostname, trust store, TLS version, and cipher suites, you can eliminate most handshake failures. Incorporate the provided script into your deployment workflow to keep environments healthy and secure.

Top comments (0)