0
votes

I have a kafka cluster on docker using confluent images. I am using docker-compose to build the containers.

When I tried to run the container it starts but can't communicate with any broker due to SSL handshake failed. I don't know if I miss some configuration

[kafka-admin-client-thread | adminclient-1] ERROR org.apache.kafka.clients.NetworkClient - [AdminClient clientId=adminclient-1] Connection to node -3 (/XXX:19092) failed authentication due to: SSL handshake failed

My Kafka brokers are configured as follows:

kafka1:

image: confluentinc/cp-kafka:5.2.2
container_name: kafka1
ports:
  - "19092:19092"
environment:
  KAFKA_BROKER_ID: 1
  KAFKA_ZOOKEEPER_CONNECT: XXX:12181,XXX:12181,XXX:12181
  KAFKA_ADVERTISED_LISTENERS: SSL://XXXX:19092
  KAFKA_SSL_KEYSTORE_FILENAME: kafka.broker1.keystore.jks
  KAFKA_SSL_KEYSTORE_CREDENTIALS: broker1_keystore_creds
  KAFKA_SSL_KEY_CREDENTIALS: broker1_sslkey_creds
  KAFKA_SSL_TRUSTSTORE_FILENAME: kafka.broker1.truststore.jks
  KAFKA_SSL_TRUSTSTORE_CREDENTIALS: broker1_truststore_creds
  KAFKA_SSL_ENDPOINT_IDENTIFICATION_ALGORITHM: ""
  KAFKA_SSL_CLIENT_AUTH: required
  KAFKA_SECURITY_INTER_BROKER_PROTOCOL: SSL
  KAFKA_SECURITY_PROTOCOL: SSL
volumes:
  - ./../../secrets:/etc/kafka/secrets

I am trying to bring a Confluent REST Proxy API into another container using the configurations:

kafka-rest-proxy:

image: confluentinc/cp-kafka-rest:5.2.2
hostname: kafka-rest-proxy
ports:
  - "18082:18082"
environment:
  KAFKA_REST_LISTENERS: "http://0.0.0.0:18082"
  KAFKA_REST_ZOOKEEPER_CONNECT: XXX:12181,XXX:12181,XXX:12181
  KAFKA_REST_HOST_NAME: kafka-rest-proxy
  KAFKA_REST_BOOTSTRAP_SERVERS: SSL://XXX:19092,SSL://XXX:19092,SSL://XXX:19092
  KAFKA_REST_CLIENT_SECURITY_PROTOCOL: SSL
  KAFKA_REST_CLIENT_SSL_KEYSTORE_LOCATION: /etc/kafka/secrets/kafka.broker1.keystore.jks
  KAFKA_REST_CLIENT_SSL_KEYSTORE_PASSWORD: XXX     
  KAFKA_REST_CLIENT_SSL_TRUSTSTORE_LOCATION: /etc/kafka/secrets/kafka.broker1.truststore.jks
  KAFKA_REST_CLIENT_SSL_TRUSTSTORE_PASSWORD: XXX
  KAFKA_REST_CLIENT_SSL_KEY_PASSWORD: XXX 
  KAFKA_REST_SSL_KEYSTORE_LOCATION: /etc/kafka/secrets/kafka.producer.keystore.jks
  KAFKA_REST_SSL_KEYSTORE_PASSWORD: XXX
  KAFKA_REST_SSL_TRUSTSTORE_LOCATION: /etc/kafka/secrets/kafka.producer.truststore.jks
  KAFKA_REST_SSL_TRUSTSTORE_PASSWORD: XXX
volumes:
  - ./../../secrets:/etc/kafka/secrets
2

2 Answers

0
votes

I configured the SSH connection only with the truststore (I removed the keystore config completely) and I used the OPTS environment variable:

docker run -d \ --name krp \ -p 8082:8082 \ ...

-v /home/ubuntu/kafka-keys:/kafka-keys \

-e KAFKA_REST_CLIENT_OPTS="-Dssl.keystore.location=/kafka-keys/kafka.client.keystore.jks -Dssl.keystore.password=changeit -Dssl.truststore.location=/kafka-keys/kafka.client.truststore.jks" \ confluentinc/cp-kafka-rest:5.3.1

And the connection worked.

0
votes

In my case (kubernetes with helm) i had to add to change

"listeners":"http://0.0.0.0:8082" to "listeners":"https://0.0.0.0:8082"

i see the same mistake in your configuration

KAFKA_REST_LISTENERS: "http://0.0.0.0:18082"

After that you will see in the end of the startup logs that it tryes to load the keystore file