kafka - ssl handshake failing
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Apache Kafka is a distributed streaming platform capable of handling trillions of events a day. To ensure data is securely transferred, Kafka supports encryption using SSL/TLS. However, setting this feature up can be quite intricate, and one of the most common issues faced during its implementation is the SSL handshake failing. This article dives into reasons for SSL handshake failures in Kafka and how to resolve them.
Understanding SSL/TLS Handshake Failures
The SSL/TLS handshake is a protocol used to securely establish communication between two systems (a client and a server in Kafka's scenario). The handshake involves the validation and exchange of security certificates, and any failure in this process can prevent a secure connection from being established. Below are some common reasons for SSL handshake failures in Kafka:
- Certificate Issues: This includes expired certificates, wrong hostnames on certificates, self-signed certificates not trusted, or missing intermediate/CA certificates.
- Cipher Suite Mismatches: If the server and the client do not support a common set of cipher suites, the SSL handshake will fail.
- SSL Protocol Mismatches: Different versions of SSL/TLS supported by the client and the server can lead to failures.
- Configuration Errors: Mistakes in the configuration files for the client or server can cause handshakes to fail, including incorrect keystore or truststore paths or passwords.
- Network Issues: Sometimes network-related issues like firewalls blocking specific ports or SSL traffic can cause these errors.
Common Scenarios and Solutions
Here are several scenarios that exemplify common Kafka SSL handshake failures along with suggested solutions:
Scenario 1: Expired Certificate
Expired certificates are a frequent cause of SSL handshake failures. To identify if this is the case:
- Use a tool like OpenSSL to check the expiry date of the certificate:
openssl x509 -in certificate.crt -text -noout - If the certificate is expired, renew it and update the corresponding keystore.
Scenario 2: Cipher Suite Mismatch
If there's a cipher suite mismatch, you will need to ensure that both Kafka server and client have common cipher suites enabled:
- Verify enabled cipher suites on the Kafka server and client.
- Adjust the
ssl.cipher.suitesparameter in both server.properties and client properties to include compatible ciphers.
Scenario 3: Incorrect Keystore or Truststore Configuration
Ensure that all paths and passwords for keystores and truststores are correctly configured:
- Check the server.properties and client properties file to confirm that the
ssl.keystore.location,ssl.keystore.password,ssl.truststore.location, andssl.truststore.passwordare set correctly. - Make sure that the files exist in the specified path and the passwords are correct.
Testing and Verifying
Once configurations are corrected based on the scenarios, run tests to verify:
- Use
kafka-console-producerandkafka-console-consumerto test if SSL handshake issues persist. - Check Kafka broker logs for any SSL handshake error messages.
Monitoring SSL Traffic
Monitoring tools like Wireshark can be used to capture and analyze SSL traffic, which can be instrumental in diagnosing handshake issues.
Summary Table
| Issue | Common Causes | Solution Suggestions | Diagnostic Tools |
| Expired Certificate | Past expiry date on certificate | Renew certificate, update keystore | OpenSSL, Keytool |
| Cipher Suite Mismatch | No common cipher suite | Adjust ssl.cipher.suites in configurations | OpenSSL, Kafka logs |
| Incorrect Configuration | Mistyped paths or passwords, wrong keystore type | Verify and correct configurations | Kafka logs, File tests |
| Protocol Version Mismatch | Unsupported SSL/TLS version | Specify correct ssl.protocol version | Kafka logs |
| Network Issues | Firewalls blocking ports or SSL traffic | Adjust firewall settings | Wireshark, Firewall logs |
Conclusion
SSL/TLS handshake failures in Kafka can stem from various sources, most notably from misconfigurations and expired certificates. Identifying the root cause is integral to resolving these issues. Regular certificate management and adherence to best practices in SSL configuration will alleviate many common problems associated with Kafka SSL handshakes.

