How to run Kafka with SASL_SSL
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 powerful distributed streaming platform capable of handling trillions of events a day. Implementing security in Kafka is essential to prevent unauthorized access to data. One common security configuration is SASL_SSL, which combines SASL (Simple Authentication and Security Layer) for authentication and SSL (Secure Sockets Layer) for encryption. This article walks through the steps and components involved in setting up Kafka with SASL_SSL.
Step 1: Configure Kafka Server
1. Configure server.properties
First, you need to set up the Kafka broker configuration to use SASL_SSL. Modify the server.properties file as follows:
Step 2: Configure JAAS for Kafka Brokers
You must create a JAAS file that Kafka will use for SASL configuration. Typically named kafka_server_jaas.conf, it might look like this:
Set the environment variable KAFKA_OPTS to ensure Kafka uses this JAAS configuration:
Step 3: Configure Kafka Client
Clients need to authenticate with the Kafka server using SASL_SSL. Update your client's client.properties file:
Create a JAAS config file for the client kafka_client_jaas.conf:
Set the environment variable to use this file:
Step 4: Generate SSL Key and Certificate
For both the Kafka server and clients, you need to create a keystore and a truststore. Use keytool for this purpose:
Step 5: Starting Kafka Server
With configurations done, start your Kafka broker:
Step 6: Testing Kafka with SASL_SSL
To ensure everything is functioning as expected, produce and consume messages with your SSL and SASL settings:
Key Configuration Parameters
| Parameter | Description |
listeners | Listener protocol and address |
security.inter.broker.protocol | Protocol used for broker communication |
sasl.mechanism.inter.broker.protocol | SASL mechanism used for broker communication |
ssl.keystore.location | Path to SSL keystore |
ssl.truststore.location | Path to SSL truststore |
sasl.enabled.mechanisms | Enabled SASL mechanisms |
Conclusion
Implementing SASL_SSL in Kafka enhances security by combining authentication and encryption, essential for protecting sensitive data in transit. By carefully configuring each component and testing connectivity, you can ensure a robust security setup in your Kafka deployment.

