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添加新的服务器连接时,报错:
随机推荐
- 矩阵之间无循环计算L2距离
实现两个矩阵的无循环计算欧氏距离 Euclidean distance navigation: 1.问题描述 2.解决方法 1.问题来源 kNN算法中会计算两个矩阵的距离 可以使用循环的方法来实现,效 ...
- [python]标准比较运算符
1. python的标准比较运算符,根据表达式的值的真假返回布尔值. 比较运算符: < <= > >= == != <> >>& ...
- Aizu-2224Save your cats并查集+最小生成树
Save your cats 题意:存在n个点,有m条边( input中读入的是 边的端点,要先转化为边的长度 ),做一个最小生成树,使得要去除的边的长度总和最小: 思路:利用并查集和求最小生成树的方 ...
- Java后端面试经验总结分享(一)
今天下午两点的时候,我去面了一家招Java开发的公司,本人工作经验2年多一丢丢. 跟大部分公司类似,先做一份笔试题,题目都比较简单,基本都写完了.我把题目以及答案列在下面一下,给自己做一下总结的,也分 ...
- JDK11,JDK12没有JRE的解决方法
jdk11和jdk12在以前版本基础上,改动有点大,安装后默认是没有jre的. 解决方法: 在JDK目录下使用bin\jlink.exe --module-path jmods --add-modul ...
- FJUT2019暑假周赛三部分题解
A本来想改到q<1e5,让你们预处理的,然后想了哈作为个逆元模板题吧= =,做不出来自行反思. B贴个题面 因为只有一次机会,那么也就是两点分布期望E = p了,先说说大家的做法,先求出每个n的 ...
- ACM代码模板
功能介绍 写了I/O函数,支持以下几种方式 read(num); //读入一个数num(任意整数类型,下同) read(num1,num2,num3,num4); //读入任意多个数 read(arr ...
- MySQL单标查询
一 单表查询的语法 #查询数据的本质:mysql会到你本地的硬盘上找到对应的文件,然后打开文件,按照你的查询条件来找出你需要的数据.下面是完整的一个单表查询的语法 select * from,这个se ...
- 关于mock
关于mock 一.什么是mock? 通俗来讲,在开发和测试过程中,由于环境不稳定或者协同开发的同事未完成等情况下,有些数据不容易构造或者不容易获取,就创建一个虚拟的对象或者数据样本,用来辅助开发或者测 ...
- JsonConvert 转DateTime类型为json 带T
在调用接口的时候 将Model转换成json Datetime类型多了个T 用的是Newtonsoft.Json.dll 版本v4.5.0.0 代码:paramsjson = JsonConvert ...