A single broker Kafka SSL setup for learning or testing.
-
Prepare environment values
cp .env.example .env
Name Note Sample KAFKA_INTERNET_HOST The host which clients connect to. 192.168.0.123 KAFKA_INTERNET_PORT Same above. Kafka will run SSL on it. 9093 KAFKA_SSL_KEY_PASSWORD Your brokers and clients share the same password. YourPassword KAFKA_MANAGER_PORT The Kafka manager port. 9000 KAFKA_CREATE_TOPICS Please check https://github.com/wurstmeister/kafka-docker#automatically-create-topics default:1:1 KAFKA_CLUSTER_NAME Just a name. test-cluster KAFKA_SECURITY_PROTOCOL PLAINTEXT
orSSL
.SSL KAFKA_SSL_CLIENT_AUTH none
,required
, orrequested
.required CA_COMMON_NAME Who are you? [email protected] CA_ORGANIZATION_UNIT Maybe your development team name? Osvlabs CA_ORGANIZATION Your company or organization. ShinetechZZ CA_LOCALITY Your city. Zhengzhou CA_STATE Your province. Henan CA_COUNTRY Your country code. CN -
Genreate CA and Key pairs into Keystores.
Needopenssl
andkeytool
./setup_ssl_for_servers.sh
-
Kafka Server
docker-compose up -d
Useopenssl s_client -debug -connect $KAFKA_INTERNET_HOST:$KAFKA_INTERNET_PORT -tls1|less
to check if SSL is working. -
Consumer
Start a console. Or run it on another computer.
client.sh
consumer.sh default
-
Producer
Start another console. Or run it on another computer.
client.sh
producer.sh default
Type anything and press enter. Then check your Consumer console.