Skip to content

Commit 35cb2d6

Browse files
authored
Merge pull request #227717 from sreekzz/patch-140
Modified Code block for Kafka 2.1
2 parents 8e75a0a + d9f8e87 commit 35cb2d6

File tree

2 files changed

+39
-13
lines changed

2 files changed

+39
-13
lines changed

articles/hdinsight/kafka/apache-esp-kafka-ssl-encryption-authentication.md

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Set up TLS encryption for communication between Kafka clients and K
44
ms.service: hdinsight
55
ms.topic: how-to
66
ms.custom: hdinsightactive
7-
ms.date: 02/14/2023
7+
ms.date: 02/17/2023
88
---
99

1010
# Set up TLS encryption and authentication for ESP Apache Kafka cluster in Azure HDInsight
@@ -201,7 +201,7 @@ These steps are detailed in the following code snippets.
201201
keytool -keystore kafka.client.keystore.jks -alias CARoot -import -file ca-cert -storepass "MyClientPassword123" -keypass "MyClientPassword123" -noprompt
202202
```
203203
204-
1. Create the file `client-ssl-auth.properties` on client machine (hn1) . It should have the following lines:
204+
1. Create the file `client-ssl-auth.properties` on client machine (hn1). It should have the following lines:
205205
206206
```config
207207
security.protocol=SASL_SSL
@@ -316,23 +316,49 @@ Run these steps on the client machine.
316316
317317
### Kafka 2.1 or above
318318
319-
1. Create a topic if it doesn't exist already.
319+
> [!Note]
320+
> Below commands will work if you are either using Kafka user or a custom user which have access to do CRUD operation.
320321
321-
```bash
322-
/usr/hdp/current/kafka-broker/bin/kafka-topics.sh --zookeeper <ZOOKEEPER_NODE>:2181 --create --topic topic1 --partitions 2 --replication-factor 2
323-
```
322+
:::image type="content" source="./media/apache-esp-kafka-ssl-encryption-authentication/access-to-crud-operation.png" alt-text="Screenshot showing how to provide access CRUD operations." border="true":::
324323
325-
1. Start console producer and provide the path to `client-ssl-auth.properties` as a configuration file for the producer.
324+
Using Command Line Tool
326325
327-
```bash
328-
/usr/hdp/current/kafka-broker/bin/kafka-console-producer.sh --broker-list <FQDN_WORKER_NODE>:9093 --topic topic1 --producer.config ~/ssl/client-ssl-auth.properties
329-
```
326+
1. Create a topic if it doesn't exist already.
327+
328+
```bash
329+
sudo su kafka –c "/usr/hdp/current/kafka-broker/bin/kafka-topics.sh --zookeeper <ZOOKEEPER_NODE>:2181 --create --topic topic1 --partitions 2 --replication-factor 2"
330+
```
331+
To use a keytab, create a JAAS file with the following content. Be sure to point the keyTab property to your keytab file and reference the principal used inside the keytab. Following is a sample JAAS file created and placed in the location in VM: **/home/hdiuser/kafka_client_jaas_keytab.conf**
332+
333+
```
334+
KafkaClient {
335+
com.sun.security.auth.module.Krb5LoginModule required
336+
useKeyTab=true
337+
storeKey=true
338+
keyTab="/home/hdiuser/espkafkauser.keytab"
339+
principal="[email protected]";
340+
};
341+
```
342+
343+
1. Start console producer and provide the path to `client-ssl-auth.properties` as a configuration file for the producer.
330344
345+
```bash
346+
export KAFKA_OPTS="-Djava.security.auth.login.config=/home/hdiuser/kafka_client_jaas_keytab.conf"
347+
348+
/usr/hdp/current/kafka-broker/bin/kafka-console-producer.sh --broker-list <FQDN_WORKER_NODE>:9093 --topic topic1 --producer.config ~/ssl/client-ssl-auth.properties
349+
```
350+
331351
1. Open another ssh connection to client machine and start console consumer and provide the path to `client-ssl-auth.properties` as a configuration file for the consumer.
332352

333-
```bash
334-
/usr/hdp/current/kafka-broker/bin/kafka-console-consumer.sh --bootstrap-server <FQDN_WORKER_NODE>:9093 --topic topic1 --consumer.config ~/ssl/client-ssl-auth.properties --from-beginning
335-
```
353+
```bash
354+
export KAFKA_OPTS="-Djava.security.auth.login.config=/home/hdiuser/kafka_client_jaas_keytab.conf"
355+
356+
/usr/hdp/current/kafka-broker/bin/kafka-console-consumer.sh --bootstrap-server <FQDN_WORKER_NODE>:9093 --topic topic1 --consumer.config ~/ssl/client-ssl-auth.properties --from-beginning
357+
```
358+
359+
If you want to use Java client to do CRUD operations, then use following GitHub repository.
360+
361+
https://github.com/Azure-Samples/hdinsight-kafka-java-get-started/tree/main/DomainJoined-Producer-Consumer-With-TLS
336362

337363
## Next steps
338364

167 KB
Loading

0 commit comments

Comments
 (0)