Kafka ssl org.apache.kafka.common.errors.SslAuthenticationException: SSL handshake failed

报错日志

exception=[ org.springframework.kafka.KafkaException: Send failed; nested exception is org.apache.kafka.common.errors.SslAuthenticationException: SSL handshake failed

2023-04-10T10:04:56.223152054Z Caused by: org.apache.kafka.common.errors.SslAuthenticationException: SSL handshake failed
2023-04-10T10:04:56.223154233Z Caused by: javax.net.ssl.SSLHandshakeException: General SSLEngine problem
2023-04-10T10:04:56.223156446Z  at sun.security.ssl.Handshaker.checkThrown(Handshaker.java:1521)
2023-04-10T10:04:56.223158686Z  at sun.security.ssl.SSLEngineImpl.checkTaskThrown(SSLEngineImpl.java:528)
2023-04-10T10:04:56.223160947Z  at sun.security.ssl.SSLEngineImpl.writeAppRecord(SSLEngineImpl.java:1197)
2023-04-10T10:04:56.223163201Z  at sun.security.ssl.SSLEngineImpl.wrap(SSLEngineImpl.java:1165)
2023-04-10T10:04:56.223165544Z  at javax.net.ssl.SSLEngine.wrap(SSLEngine.java:469)
2023-04-10T10:04:56.223167756Z  at org.apache.kafka.common.network.SslTransportLayer.handshakeWrap(SslTransportLayer.java:473)
2023-04-10T10:04:56.223169996Z  at org.apache.kafka.common.network.SslTransportLayer.doHandshake(SslTransportLayer.java:336)
2023-04-10T10:04:56.223172145Z  at org.apache.kafka.common.network.SslTransportLayer.handshake(SslTransportLayer.java:286)
2023-04-10T10:04:56.223176818Z  at org.apache.kafka.common.network.KafkaChannel.prepare(KafkaChannel.java:173)
2023-04-10T10:04:56.223179109Z  at org.apache.kafka.common.network.Selector.pollSelectionKeys(Selector.java:547)
2023-04-10T10:04:56.223181388Z  at org.apache.kafka.common.network.Selector.poll(Selector.java:485)
2023-04-10T10:04:56.223183598Z  at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:550)
2023-04-10T10:04:56.223185821Z  at org.apache.kafka.clients.producer.internals.Sender.runOnce(Sender.java:324)
2023-04-10T10:04:56.223188045Z  at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:239)
2023-04-10T10:04:56.223190168Z  at java.lang.Thread.run(Thread.java:748)
2023-04-10T10:04:56.223192210Z Caused by: javax.net.ssl.SSLHandshakeException: General SSLEngine problem
2023-04-10T10:04:56.223194358Z  at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
2023-04-10T10:04:56.223196503Z  at sun.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1709)
2023-04-10T10:04:56.223198766Z  at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:318)
2023-04-10T10:04:56.223200976Z  at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:310)
2023-04-10T10:04:56.223203156Z  at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1639)
2023-04-10T10:04:56.223205400Z  at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:223)
2023-04-10T10:04:56.223207637Z  at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1037)
2023-04-10T10:04:56.223209751Z  at sun.security.ssl.Handshaker$1.run(Handshaker.java:970)
2023-04-10T10:04:56.223212290Z  at sun.security.ssl.Handshaker$1.run(Handshaker.java:967)
2023-04-10T10:04:56.223214464Z  at java.security.AccessController.doPrivileged(Native Method)
2023-04-10T10:04:56.223216681Z  at sun.security.ssl.Handshaker$DelegatedTask.run(Handshaker.java:1459)
2023-04-10T10:04:56.223218906Z  at org.apache.kafka.common.network.SslTransportLayer.runDelegatedTasks(SslTransportLayer.java:425)
2023-04-10T10:04:56.223221225Z  at org.apache.kafka.common.network.SslTransportLayer.handshakeUnwrap(SslTransportLayer.java:509)
2023-04-10T10:04:56.223223500Z  at org.apache.kafka.common.network.SslTransportLayer.doHandshake(SslTransportLayer.java:363)
2023-04-10T10:04:56.223231190Z  ... 8 more
Caused by: sun.security.validat
or.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

问题由来:
aliyun kafka 使用ssl从公网连接,之前使用的证书好好的,过了一段时间发现不太行了

解决思路:
证书问题,更换官方推荐的证书,即修复了问题
旧的证书:kafka.client.truststore.jks
新的证书:only.4096.client.truststore.jks

https://help.aliyun.com/document_detail/68325.html?spm=a2c4g.182891.0.0.47886899npQlBO

你可能感兴趣的:(线上问题,kafka,java)