Confluent REST 代理 API SSL 握手失败

Confluent REST proxy API SSL handshake fails

我在 docker 上有一个使用融合图像的 kafka 集群。我正在使用 docker-compose 构建容器。

当我尝试 运行 容器时,它启动但由于 SSL 握手失败而无法与任何代理通信。不知道是不是漏掉了一些配置

[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

我的Kafka代理配置如下:

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

我正在尝试使用以下配置将 Confluent REST 代理 API 引入另一个容器:

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

在我的情况下(带头盔的 kubernetes)我不得不添加更改

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

我在你的配置中看到了同样的错误

KAFKA_REST_LISTENERS: "http://0.0.0.0:18082"

之后您将在启动日志的末尾看到它尝试加载密钥库文件

我只使用信任库配置了 SSH 连接(我完全删除了密钥库配置)并且我使用了 OPTS 环境变量:

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

连接正常。