通过 TLS 将 Kafka producer/consumer 连接到代理
Connecting Kafka producer/consumer to broker via TLS
我正在尝试为 kafka 代理设置 TLS。我已按照 here 的步骤进行操作,并能够使用 TLS 设置 Kafka。 (在日志中,我看到配置端口的 SSL 条目)。
现在我遇到了连接 producer/consumer 的问题。
我使用以下命令创建了一个客户端密钥库,
keytool -keystore client.keystore.jks -alias localhost -validity 365 -keyalg RSA -genkey
将 CA 证书添加到密钥库,
keytool -keystore client.keystore.jks -alias CARoot -import -file ca-cert
运行 客户端中的以下命令,其中 ca-cert
是服务器上使用的证书。
keytool -keystore client.truststore.jks -alias CARoot -import -file ca-cert
keytool -keystore client.keystore.jks -alias localhost -validity 365 -keyalg RSA -genkey
keytool -keystore client.keystore.jks -alias CARoot -import -file ca-cert
在producer.properties
、
中添加了以下配置
security.protocol=SSL
ssl.truststore.location=path to client.truststore.jks
ssl.truststore.password=<password>
ssl.keystore.location=path to client.keystore.jks
ssl.keystore.password=<password>
ssl.key.password=<password>
运行 kafka-console-producer
kafka-console-producer.sh --broker-list 0.0.0.0:9092 --topic test --producer.config ../config/producer.properties
但是当 运行 util,
时出现以下错误
WARN Connection to node -1 terminated during authentication. This may
indicate that authentication failed due to invalid credentials.
(org.apache.kafka.clients.NetworkClient)
怀疑我在客户端配置中遗漏了一些东西。任何帮助将不胜感激。
您正在尝试使用客户端证书吗?相反,我会建议,尝试不使用客户端证书。在这种情况下,您只需要以下条目,
producer.properties
文件:-
security.protocol=SSL
ssl.truststore.location=/<path-to>/truststore.jks
ssl.truststore.type=JKS
在此处了解更多信息 - http://kafka.apache.org/documentation/#security_configclients
对于客户端身份验证,kafka 使用 SASL,文档的这一部分涵盖了它 - http://kafka.apache.org/documentation/#security_sasl
我正在尝试为 kafka 代理设置 TLS。我已按照 here 的步骤进行操作,并能够使用 TLS 设置 Kafka。 (在日志中,我看到配置端口的 SSL 条目)。
现在我遇到了连接 producer/consumer 的问题。
我使用以下命令创建了一个客户端密钥库,
keytool -keystore client.keystore.jks -alias localhost -validity 365 -keyalg RSA -genkey
将 CA 证书添加到密钥库,
keytool -keystore client.keystore.jks -alias CARoot -import -file ca-cert
运行 客户端中的以下命令,其中
ca-cert
是服务器上使用的证书。keytool -keystore client.truststore.jks -alias CARoot -import -file ca-cert keytool -keystore client.keystore.jks -alias localhost -validity 365 -keyalg RSA -genkey keytool -keystore client.keystore.jks -alias CARoot -import -file ca-cert
在
中添加了以下配置producer.properties
、security.protocol=SSL ssl.truststore.location=path to client.truststore.jks ssl.truststore.password=<password> ssl.keystore.location=path to client.keystore.jks ssl.keystore.password=<password> ssl.key.password=<password>
运行
kafka-console-producer
kafka-console-producer.sh --broker-list 0.0.0.0:9092 --topic test --producer.config ../config/producer.properties
但是当 运行 util,
时出现以下错误WARN Connection to node -1 terminated during authentication. This may indicate that authentication failed due to invalid credentials. (org.apache.kafka.clients.NetworkClient)
怀疑我在客户端配置中遗漏了一些东西。任何帮助将不胜感激。
您正在尝试使用客户端证书吗?相反,我会建议,尝试不使用客户端证书。在这种情况下,您只需要以下条目,
producer.properties
文件:-
security.protocol=SSL
ssl.truststore.location=/<path-to>/truststore.jks
ssl.truststore.type=JKS
在此处了解更多信息 - http://kafka.apache.org/documentation/#security_configclients
对于客户端身份验证,kafka 使用 SASL,文档的这一部分涵盖了它 - http://kafka.apache.org/documentation/#security_sasl