ssl - Zookeeper TLS 错误 : Unsuccessful handshake with session 0x0 (org. apache.zookeeper.server.NettyServerCnxnFactory)

标签 ssl apache-zookeeper tls1.2

无法使用 TSL 启动 Zookeeper,请帮助我!

Zookeeper 版本:3.5.8-f439ca583e70862c3068a1f2a7d4d068eec33315,构建于 05/04/2020 15:53 GMT

zookeeper.属性:

###################[ MAIN ]###################
dataDir=~/zookeeper_ssl/data/zookeeper-data    
clientPort=2185    
secureClientPort=2186    
maxClientCnxns=0     

##############[ AUTHENTICATION ]##############

authProvider.sasl=org.apache.zookeeper.server.auth.SASLAuthenticationProvider # (tried change to authProvider.1 but no success)    
jaasLoginRenew=3600000    
requireClientAuthScheme=sasl    

#############[ SSL ]############    authProvider.x509=org.apache.zookeeper.server.auth.X509AuthenticationProvider # (tried to remove - but no success)    
serverCnxnFactory=org.apache.zookeeper.server.NettyServerCnxnFactory    
ssl.keyStore.location=~/zookeeper_ssl/ssl/broker1.jks    
ssl.keyStore.password=xxx    
ssl.trustStore.location=~/zookeeper_ssl/ssl/broker1.jks    
ssl.trustStore.password=xxx    
clientAuth=none     
tickTime=3000    
initLimit=10    
syncLimit=5

##############[ OTHER CONFIGS ]#############    
4lw.commands.whitelist=*    
admin.enableServer=true    
admin.serverPort=8181

一切都开始顺利。然后尝试连接:

./bin/kafka-run-class \
> -Dzookeeper.clientCnxnSocket=org.apache.zookeeper.ClientCnxnSocketNetty \
> -Dzookeeper.ssl.client.enable=true \
> -Dzookeeper.ssl.keyStore.location=~/zookeeper_ssl/ssl/dev1.jks \
> -Dzookeeper.ssl.keyStore.password=xxx \
> -Dzookeeper.ssl.trustStore.location=~/zookeeper_ssl/ssl/dev1.jks \
> -Dzookeeper.ssl.trustStore.password=xxx \
> org.apache.zookeeper.ZooKeeperMain -server localhost:2186

已获得:

连接到本地主机:2186
欢迎来到 ZooKeeper!
JLine 支持已禁用
实际上这里什么也没发生 - 所以按 CTRL+C ^C

zookeeper.log:

[2020-08-17 18:02:07,667] DEBUG Using Java8 optimized cipher suites for Java version 1.8 (org.apache.zookeeper.common.X509Util)

[2020-08-17 18:02:07,981] DEBUG Default protocols (JDK): [TLSv1.2, TLSv1.1, TLSv1]  (io.netty.handler.ssl.JdkSslContext)

[2020-08-17 18:02:07,981] DEBUG Default cipher suites (JDK): [TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA] (io.netty.handler.ssl.JdkSslContext)

[2020-08-17 18:02:08,104] DEBUG SSL handler added for channel: [id: 0x6bcbf86b, L:/x.x.x.x:2186 - R:/x.x.x.x:56620] (org.apache.zookeeper.server.NettyServerCnxnFactory)

[2020-08-17 18:02:08,123] DEBUG -Dio.netty.recycler.maxCapacityPerThread: 4096 (io.netty.util.Recycler)

[2020-08-17 18:02:08,123] DEBUG -Dio.netty.recycler.maxSharedCapacityFactor: 2 (io.netty.util.Recycler)

[2020-08-17 18:02:08,123] DEBUG -Dio.netty.recycler.linkCapacity: 16 (io.netty.util.Recycler)

[2020-08-17 18:02:08,123] DEBUG -Dio.netty.recycler.ratio: 8 (io.netty.util.Recycler)

[2020-08-17 18:02:08,133] DEBUG -Dio.netty.buffer.checkAccessible: true (io.netty.buffer.AbstractByteBuf)

[2020-08-17 18:02:08,133] DEBUG -Dio.netty.buffer.checkBounds: true (io.netty.buffer.AbstractByteBuf)

[2020-08-17 18:02:08,134] DEBUG Loaded default ResourceLeakDetector: io.netty.util.ResourceLeakDetector@3021f880 (io.netty.util.ResourceLeakDetectorFactory)

[2020-08-17 18:02:08,149] ERROR Unsuccessful handshake with session 0x0 (org.apache.zookeeper.server.NettyServerCnxnFactory)

[2020-08-17 18:02:08,149] DEBUG close called for sessionid:0x0 (org.apache.zookeeper.server.NettyServerCnxn)

[2020-08-17 18:02:08,149] DEBUG cnxns size:0 (org.apache.zookeeper.server.NettyServerCnxn)

[2020-08-17 18:02:08,153] WARN Exception caught (org.apache.zookeeper.server.NettyServerCnxnFactory)

io.netty.handler.codec.DecoderException: io.netty.handler.ssl.NotSslRecordException: not an SSL/TLS record: 0000002d000000000000000000000000000075300000000000000000000000100000000000000000000000000000000000

        at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:468)

        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)

        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)

        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)

        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)

        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)

        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)

        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)

        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)

        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)

        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714)

        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650)

        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576)

        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)

        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)

        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)

        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)

        at java.lang.Thread.run(Thread.java:745)

Caused by: io.netty.handler.ssl.NotSslRecordException: not an SSL/TLS record: 0000002d000000000000000000000000000075300000000000000000000000100000000000000000000000000000000000

        at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1214)

        at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1282)

        at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:498)

        at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:437)

        ... 17 more

[2020-08-17 18:02:08,153] DEBUG Closing  /x.x.x.x:56620[0](queued=0,recved=0,sent=0) (org.apache.zookeeper.server.NettyServerCnxnFactory)

[2020-08-17 18:02:08,153] DEBUG close called for sessionid:0x0 (org.apache.zookeeper.server.NettyServerCnxn)

[2020-08-17 18:02:08,153] DEBUG cnxns size:0 (org.apache.zookeeper.server.NettyServerCnxn)

jks内部

keystore broker1.jks

Alias name: zserver
Entry type: PrivateKeyEntry
Owner: CN=zserver, C=RU


Alias name: dev1
Entry type: trustedCertEntry
Owner: CN=dev1, C=RU

keystore dev1.jks

Alias name: zserver
Entry type: trustedCertEntry
Owner: CN=zserver, C=RU


Alias name: dev1
Entry type: PrivateKeyEntry
Owner: CN=dev1, C=RU

最佳答案

已发现问题 - 正确的参数是:

-Dzookeeper.client.secure=true

(Dzookeeper.ssl.client.enable=true 是错误的)

关于ssl - Zookeeper TLS 错误 : Unsuccessful handshake with session 0x0 (org. apache.zookeeper.server.NettyServerCnxnFactory),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63454716/

相关文章:

ubuntu - 我们可以在两个不同的主机上使用一个 SSL 证书吗

node.js - 我无法为我的 Google App Engine 禁用 http 请求

hadoop - 关于hbase,zookeeper.MetaTableLocator:无法验证hbase:meta,.NotServingRegionException

docker - 卡夫卡和动物园管理员之间的注册流程

mysql - 使用 Python 3.7 与 MySQL 的 SSL 连接错误。接口(interface)错误 : SSL connection error: Failed to set ciphers to use

postgresql - 从 wildfly 设置 Postgres SSL 连接

ssl - 外部网站的自签名证书

ssl - 2 路 SSL/TLS 配置

hadoop - HBase HDFS 动物园管理员

ssl - CFNetwork SSLHandshake 间歇性失败 (-9806)