Received fatal alert handshake_failure through SSLHandshakeException
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
SSLHandshakeException and Handshake Failures
Establishing a secure connection on the internet often involves using protocols like HTTPS, which relies on SSL/TLS to encrypt and secure data transmitted between a client and a server. During this process, a crucial step is the SSL/TLS handshake—a series of messages exchanged between the client and server to authenticate each other and agree on encryption algorithms. Occasionally, issues can occur during this handshake, resulting in errors such as the SSLHandshakeException: "Received fatal alert: handshake_failure."
Understanding SSLHandshakeException
The SSLHandshakeException is a subclass of the IOException in Java, signaling that the SSL handshake has failed. Handshake failures can occur due to a variety of reasons, including misconfigurations, mismatches in supported protocols, or certificate issues.
Common Causes of Handshake Failures
- Protocol Mismatch: If the client and server support different SSL/TLS versions or ciphers, the handshake will fail.
- Certificate Issues: The server's certificate might be expired, untrusted, or not matching the hostname.
- Configuration Errors: Misconfigured server settings, like incorrect SSL certificate names or unsupported cipher suites.
- Firewall or Proxy: Network devices intercepting SSL traffic can disrupt the handshake process.
- Client-Side Restrictions: Older clients might not support modern cipher suites or TLS protocols.
Example Scenario
Consider an example where a Java client application attempts to connect to a HTTPS server, but encounters an SSLHandshakeException:
In this scenario, debugging the issue begins by checking the supported SSL/TLS protocols and cipher suites on both the client and server. Ensuring they have a common protocol and cipher suite is essential. Additionally, reviewing the server's certificate for validity and correctness might be necessary.
Diagnosing Handshake Issues
To diagnose a handshake failure effectively:
- Capture and Analyze Network Traffic: Tools like Wireshark can capture the TLS handshake process. Analyze this data to identify mismatches or protocol errors.
- Enable Debugging: Java applications can add the following JVM argument to produce detailed SSL logs:
- Server Logs: Check server-side logs for additional insights regarding the failure.
Solutions for Handshake Failures
- Updating Protocols and Ciphers: Ensure the server and client are configured to support compatible SSL/TLS versions and cipher suites.
- Check Certificate Configuration: Validate that the server certificate is not expired and is correctly configured with the hostname.
- Client Configuration: Make sure the client's Java environment supports the needed protocols, especially on older versions.
- Firewall and Network Settings: Confirm network devices do not interfere with the handshake process.
Summary Table
Here is a table to summarize key factors related to handshake failures:
| Factor | Description |
| Protocol Mismatch | Incompatibility in supported SSL/TLS versions. |
| Certificate Errors | Issues with expiration, hostname mismatch, or trust. |
| Configuration Errors | Incorrect setups, like unsupported cipher suites. |
| Network Interferences | Firewalls or proxies disrupting the SSL traffic. |
| Client-Side Restrictions | Outdated clients lacking modern protocol support. |
By understanding these factors and following thorough diagnostic steps, handshake failures can be addressed efficiently, ensuring smooth and secure communications between clients and servers.
Related reading
- Recommended GCE service account authentication inside Docker container?
- Recommended way to manage credentials with multiple AWS accounts?
- Refreshing OAuth token using Retrofit without modifying all calls
- Regex for password must contain at least eight characters, at least one number and both lower and uppercase letters and special characters
- Receiving Email is not working in Amazon SES
- Receiving kAUGraphErr_CannotDoInCurrentContext when calling AUGraphStart for playback
- Remove all the Kafka ACLs
- Remove credentials from Git

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.