- Zookeeper and the Kafka broker are running and want to connect via SSL handshake.
- Both services have:
- Their own CA-signed certificate in the keystore.
- The same CA certificate (ca-cert) from the CA in the truststore.
- The broker sends its CA-signed certificate to Zookeeper.
- Zookeeper verifies the broker's certificate using the CA certificate (ca-cert) in its truststore.
- Upon verification, Zookeeper sends its own CA-signed certificate to the broker.
- The broker verifies Zookeeper's certificate using the CA certificate (ca-cert) in its truststore.
- Once both certificates are verified, they start secure communication.
-
Generate CA Key and Certificate:
openssl req -new -x509 -keyout ca-key -out ca-cert -days 3650
- Creates a new CA private key (
ca-key) and self-signed CA certificate (ca-cert).
- Creates a new CA private key (
-
Create Truststore and Import CA Certificate:
keytool -keystore kafka.zookeeper.truststore.jks -alias ca-cert -import -file ca-cert
- Creates a truststore (
kafka.zookeeper.truststore.jks) and imports the CA certificate.
- Creates a truststore (
-
Create Keystore and Generate a Key Pair:
keytool -keystore kafka.zookeeper.keystore.jks -alias zookeeper -validity 3650 -genkey -keyalg RSA -ext SAN=dns:localhost
- Creates a keystore (
kafka.zookeeper.keystore.jks) and generates a key pair for Zookeeper.
- Creates a keystore (
-
Create Certificate Signing Request (CSR):
keytool -keystore kafka.zookeeper.keystore.jks -alias zookeeper -certreq -file ca-request-zookeeper
- Generates a CSR (
ca-request-zookeeper) using the Zookeeper key pair.
- Generates a CSR (
-
Sign the CSR with CA Certificate:
openssl x509 -req -CA ca-cert -CAkey ca-key -in ca-request-zookeeper -out ca-signed-zookeeper -days 3650 -CAcreateserial
- Signs the CSR to create a CA-signed certificate (
ca-signed-zookeeper).
- Signs the CSR to create a CA-signed certificate (
-
Import CA Certificate into Keystore::
keytool -keystore kafka.zookeeper.keystore.jks -alias ca-cert -import -file ca-cert
- Imports the CA certificate into Zookeeper's keystore.
-
Import the Signed Certificate into Keystore:
keytool -keystore kafka.zookeeper.keystore.jks -alias zookeeper -import -file ca-signed-zookeeper
- Imports the CA-signed certificate into Zookeeper's keystore.
