5

When we connect to Kafka cluster/kafka, In the java clients we define certain properties -
Example Producer Properties

 Properties props = new Properties();
 props.put("bootstrap.servers", "localhost:9092");
 props.put("acks", "all");
 props.put("retries", 0);
 props.put("batch.size", 16384);
 props.put("linger.ms", 1);
 props.put("buffer.memory", 33554432);
 props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
 props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");

Example Consumer Properties -

Properties props = new Properties();
props.setProperty("bootstrap.servers", "localhost:9092");
props.setProperty("group.id", "test");
props.setProperty("enable.auto.commit", "true");
props.setProperty("auto.commit.interval.ms", "1000");
props.setProperty("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
props.setProperty("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");

Similarly, should any properties (like keystore and truststore path, etc) related to the SSL-Auth be mentioned here when connecting to Kafka Cluster secured with SSL-Auth.
Could someone elaborate and explain how the java client can connect to a secured Kafka cluster.

Ref - Above props have been taken from Kafka docs - kafka producer / kafka consumer

samshers
  • 1
  • 6
  • 37
  • 84

1 Answers1

4

There's a section in the Kafka docs that details how to configure SSL authentication: http://kafka.apache.org/documentation/#security_ssl

In the Configuring Kafka clients section, it lists the required settings:

# For SSL
security.protocol=SSL
ssl.truststore.location=/var/private/ssl/client.truststore.jks
ssl.truststore.password=test1234

# For SSL auth
ssl.keystore.location=/var/private/ssl/client.keystore.jks
ssl.keystore.password=test1234
ssl.key.password=test1234
Mickael Maison
  • 25,067
  • 7
  • 71
  • 68
  • 1
    so, things like - `props.setProperty("ssl.keystore.location", "var/private/ssl/client.keystore.jks");` etc – samshers Jul 09 '20 at 10:07
  • 1
    Yes, set these configuration on your Properties/Map object used to create the Kafka client. `ssl.key.password` is the password of the private key in the key store file, this is optional if you've not set a password on the key – Mickael Maison Jul 09 '20 at 11:36