Kafka
Authentication Failure
SSL Handshake
Cybersecurity
Server Communication

Kafka "Failed authentication due to: SSL handshake failed"

Codemia Knowledge Hub ·

Kafka reports "SSL handshake failed" when the client and broker cannot complete the TLS handshake. The usual causes are an invalid or expired certificate, a misconfigured keystore or truststore, incompatible TLS versions, or no shared cipher suite. Fix the one that applies and the connection goes through.

What happens during the handshake

With SSL configured, the client and broker must complete a handshake before any data is sent. During it they exchange encryption keys, authenticate each other and agree on session security parameters. If any step fails, the connection is terminated and Kafka logs an error such as "SSL handshake failed". (TLS is the successor to SSL; Kafka's settings still use the SSL name.)

Causes and fixes

  1. Invalid or expired certificates. Certificates prove each party's identity, so an untrusted or expired one fails the handshake. Make sure certificates are valid and trusted by both sides, and check the expiry date and issuer.
  2. Incompatible protocol versions. If the client and broker are set to SSL or TLS versions that do not overlap, the handshake cannot succeed. Configure both to use compatible TLS versions.
  3. Incorrect SSL configuration. Wrong keystore or truststore paths, passwords or types break the handshake. Review them on both sides.
  4. Cipher suite mismatch. If client and broker have no cipher suite in common, the handshake fails. Make sure their enabled suites overlap.

Example: bad_certificate from the broker

A client fails to connect, and the log points to the certificate:

 
[2023-01-15 08:23:45,024] ERROR [SslTransportLayer]: SSL handshake failed (org.apache.kafka.common.network.SslTransportLayer)
javax.net.ssl.SSLHandshakeException: Received fatal alert: bad_certificate

To resolve it:

  1. Check the certificates used by the client and the broker. Renew or reissue any that are invalid or expired.
  2. Review the configuration in the broker's server.properties and the client's configuration so every SSL-related setting is correct.
  3. Raise logging for SSL events on both client and broker to get detailed errors.
  4. Test the connection by hand with openssl s_client -connect <broker>:<port> for more diagnostic information.
IssuePotential CausesResolution Steps
SSL Handshake Failure- Expired certificates - Incompatible SSL/TLS versions - Misconfiguration - Cipher mismatch- Verify and renew certificates - Ensure protocol compatibility - Review configurations - Confirm and adjust cipher suites

SSL/TLS encrypts traffic between Kafka clients and brokers, which matters most where the cluster handles sensitive data. When a handshake fails, work through certificates, protocol versions, keystore and truststore configuration, and cipher suites, raising SSL logging on both sides until the failing step is clear.


Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design