SpringBoot 连接kafka ssl 报 CertificateException: No subject alternative names present 异常解决
当使用较新版本SpringBoot时,对应的 kafka-client 版本也比较新,如果使用了 2.x 以上的 kafka-client ,并且配置了 kafka ssl 连接方式时,可能会报如下异常:
javax.net.ssl.SSLException: Inbound closed before receiving peer's close_notify: possible truncation attack? ..... org.apache.kafka.common.errors.SslAuthenticationException: SSL handshake failed
Caused by: javax.net.ssl.SSLHandshakeException: General SSLEngine problem ..... Caused by: java.security.cert.CertificateException: No subject alternative names present ..... 2019-10-09 10:12:55.683 DEBUG 23524 --- [ main] o.s.kafka.core.KafkaTemplate : Failed to send: ProducerRecord .....
该原因是因为新版本 kafka-client 会校验证书的主机名,配置忽略主机名校验即可。
配置方法主要代码如下:
spring:
kafka:
properties:
ssl:
endpoint:
identification:
algorithm: ''
另附SpringBoot 使用 ssl 证书连接 kafka 完整配置如下:
########## kafka ##########
spring:
kafka:
producer:
batch-size: 16384
retries: 1
buffer-memory: 33554432
bootstrap-servers: 192.168.1.100:9092
value-serializer: org.apache.kafka.common.serialization.StringSerializer
key-serializer: org.apache.kafka.common.serialization.StringSerializer
consumer:
group-id: test-group-001
auto-offset-reset: earliest
auto-commit-interval: 100
bootstrap-servers: 192.168.1.100:9092
value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
enable-auto-commit: true
ssl:
protocol: SSL
trust-store-type: JKS
trust-store-location: file:D:/source-files/kafka/kafkatest.client.truststore.test.jks
trust-store-password: 123456
key-store-type: JKS
key-store-location: file:D:/source-files/kafka/kafkatest.client.keystore.test.jks
key-store-password: 123456
key-password: 123456
properties:
ssl:
endpoint:
identification:
algorithm: ''
security:
protocol: SSL
问题解决。
SpringBoot 连接kafka ssl 报 CertificateException: No subject alternative names present 异常解决的更多相关文章
- java.security.cert.CertificateException: No subject alternative names present
背景:在开发一个项目中,要调用一个webservice服务,之前设置的是http协议,项目中采用jdk自带的wsimport工具生成的客户端代码; 后来,需求变更要求兼容https协议的webserv ...
- JDK安全证书的一个错误消息 No subject alternative names present的解决办法
我使用Java消费某网站一个Restful API时,遇到这个错误: 21:31:16.383 [main] DEBUG org.springframework.web.client.RestTemp ...
- 用HttpClient发送HTTPS请求报SSLException: Certificate for <域名> doesn't match any of the subject alternative names问题的解决
最近用server酱-PushBear做消息自动推送,用apache HttpClient做https的get请求,但是代码上到服务器端就报javax.net.ssl.SSLException: Ce ...
- java.security.cert.CertificateException: No subject alternative names matching IP address xxx.xxx.xxx.xxx found
https与http不同的是,https加密,需要验证证书,而http不需要. 在连接的代码中加上: static { disableSslVerification(); } private stat ...
- 【java细节】Java代码忽略https证书:No subject alternative names present
https://blog.csdn.net/audioo1/article/details/51746333
- 关于springboot 连接mysql 数据库报错问题
springboot连接MySQL运行报错: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more ...
- 使用HttpClient携带证书报错_Certificate for <IP> doesn't match any of the subject alternative names:[域名]
使用HttpClient携带pfx证书通过Https协议发送SOUP报文调用WebService接口时报如下错误: Exception in thread "main" javax ...
- Aandroid 解决apk打包过程中出现的“Certificate for <jcenter.bintray.com> doesn't match any of the subject alternative names: [*.aktana.com, aktana.com]”的问题
有时候,apk打包过程中会出现“Certificate for <jcenter.bintray.com> doesn't match any of the subject alterna ...
- 【PostgreSQL】PostgreSQL添加新服务器连接时,报错“Server doesn't listen ”,已解决。
PostgreSQL添加新的服务器连接时,报错:
随机推荐
- 实参&形参
实参VS形参 1.实参 argument 实际参数,在函数调用的时候,传递给函数的参数.实参-按值调用 实际参数可以是变量.常量.表达式以及函数 实际参数必须得有确定的值(赋值.输入等),在函数调用时 ...
- 【selenium】- webdriver常见api
本文由小编根据慕课网视频亲自整理,转载请注明出处和作者. 1.常见API 2.打开网址 3.操作浏览器 quit()没有完全关闭进程,依旧占用资源. 4.输入框操作 5.选择框操作 6.特殊窗口操作 ...
- lightoj 1036 - A Refining Company(简单dp)
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1036 题解:设dp[i][j]表示处理到(i,j)点时的最大值然后转移显然是 ...
- 数论 线性同余方程的应用 poj2891
Strange Way to Express Integers Time Limit: 1000MS Memory Limit: 131072K Total Submissions: 17321 ...
- 【Offer】[45]【把数组排成最小的数】
题目描述 思路分析 测试用例 Java代码 代码链接 题目描述 输入一个正整数数组,把数组里所有数字拼接起来排成一个数,打印能拼接出的所有数字中最小的一个.例如,输入数组{3,32,321},则打印出 ...
- Day003_Linux基础——系统目录结构
Linux系统的目录结构: 圆型节点代指目录,方型节点代指文件. 图中省去了很多不常用的目录与文件. 稍后单独讲/proc目录与/var目录. /usr 目录. /usr/local 用户个人安装的软 ...
- Android之MVP设计模式
一.概述 MVP设计模式的前身是MVC,这个无需再议 在安卓工程中MVC对应关系如下: Layout->View : 对应布局文件Activity->Controller,View (其中 ...
- SQL DROP INDEX 语句
SQL DROP INDEX 语句 我们可以使用 DROP INDEX 命令删除表格中的索引. 用于 Microsoft SQLJet (以及 Microsoft Access) 的语法: DROP ...
- Java第三次作业第一题
1.[请复制本程序,作为java程序代码,进行编译,补充填写缺失代码部分,并实现题目要求功能,从而获得空白填写所需的内容.] 编写无限计时程序,从0:1开始计时,一直循环计时,计时到60秒,变为1:0 ...
- 13 (OC)* SDWebImage
IOS SDWebImage实现原理详解 在之前我写过SDWebImage的使用方法,主要是用与获取网络图片,没有看过的朋友可以看看. 这篇文章将主要介绍SDWebImage的实现原理,主要针对于 ...