java - 在 KAFKA 中启用 SSL 时出现 SSL 握手错误

标签 java linux rhel7

当我启动生产者推送数据时,我的 SSL 握手失败,做了以下设置:

1. Followed steps as per 
    https://docs.confluent.io/2.0.0/kafka/ssl.html to create keystore
2.  Started zookeeper with default settings
3.  Made below changes in kafka server properties:
    a.  listeners=SSL://hostName:9092
    b.  ssl.keystore.location =/home/kafka_2.12- 
       2.2.0/kafka.server.keystore.jks
    c.  ssl.keystore.password =keystore
    d.  ssl.key.password =keystore
    e.  ssl.truststore.location =/home/kafka_2.12- 
       2.2.0/kafka.server.truststore.jks
    f.  ssl.truststore.password =keystore
    g.  ssl.endpoint.identification.algorithm=HTTPS
    h.  advertised.listeners=SSL://hostName:9092
    i.  inter.broker.listener.name=SSL
    j.  listener.security.protocol.map=SSL:SSL

完成上述步骤后,我就可以启动kafka服务器了,服务器就启动了。

Command bin/zookeeper-shell.sh localhost:2181 <<< "get /brokers/ids/0" gave below output that means broker id 0 was up and listening  on 
SSL://hostName:9092
Connecting to localhost:2181
Welcome to ZooKeeper!
JLine support is disabled
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
{"listener_security_protocol_map":{"SSL":"SSL"},"endpoints": 
["SSL://hostName:9092"]
 ,"jmx_port":-1,"host":null,"timestamp":"1559106754150" 
 ,"port":-1,"version":4}
cZxid = 0x425
ctime = Wed May 29 10:42:34 IST 2019
mZxid = 0x425
mtime = Wed May 29 10:42:34 IST 2019
pZxid = 0x425
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x1004d6fe052000a
dataLength = 159
numChildren = 0

但是当我启动 kafka 生产者推送数据时,我在 kafka 服务器控制台上收到 SSL 握手错误

开始生产者 bin/kafka-console-producer.sh --broker-list hostName:9092 --topic test3

[2019-05-29 10:45:57,808] INFO [SocketServer brokerId=0] Failed 
authentication with /101.101.101.101 (SSL handshake failed) 
(org.apache.kafka.common.network.Selector)
[2019-05-29 10:45:58,143] INFO [SocketServer brokerId=0] Failed 
authentication with /101.101.101.101 (SSL handshake failed) 
(org.apache.kafka.common.network.Selector)
[2019-05-29 10:45:58,728] INFO [SocketServer brokerId=0] Failed 
authentication with /101.101.101.101 (SSL handshake failed) 
(org.apache.kafka.common.network.Selector)
[2019-05-29 10:45:59,613] INFO [SocketServer brokerId=0] Failed 
authentication with /101.101.101.101 (SSL handshake failed) 
(org.apache.kafka.common.network.Selector)
[2019-05-29 10:46:00,600] INFO [SocketServer brokerId=0] Failed 
authentication with /101.101.101.101 (SSL handshake failed) 
(org.apache.kafka.common.network.Selector)
[2019-05-29 10:46:01,688] INFO [SocketServer brokerId=0] Failed 
authentication with /101.101.101.101 (SSL handshake failed) 
(org.apache.kafka.common.network.Selector)
[2019-05-29 10:46:02,928] INFO [SocketServer brokerId=0] Failed 
authentication with /101.101.101.101 (SSL handshake failed) 
(org.apache.kafka.common.network.Selector)

注意:Kafka broker server 和 producer 在同一台主机上

期望生产者应该将数据推送到在同一本地主机上运行的代理。 来自另一个节点的消费者应该能够消费。 数据应该加密,因为我们启用了 SSL

最佳答案

使用单向握手。 现在通过实现双向握手解决了这个问题

关于java - 在 KAFKA 中启用 SSL 时出现 SSL 握手错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56358273/

相关文章:

Java + Hibernate4 + GWT + App Engine = InitialContext 错误

java - 获取子字符串正则表达式java

linux - FTP 绑定(bind)到特定接口(interface)

linux - Teradata 的 Pyodbc 问题

linux - 设置变量与环境变量 Linux(debian) Bash shell

java - 获取 AWS IoT CA 证书信息

java - 创建一个存储语音的按钮

redis - 为什么我们需要 Redis 来运行 CKAN?

java - 如何使用 Rhel 创建 Dockerfile 文件

linux - 为什么 Bash 变量在 if 语句内为空,但在 if 语句外却不为空?