SpringBoot 实现Https双向认证 + 证书热加载
实现原理
使用自定义javax.net.ssl.X509TrustManager,自定义证书验证逻辑,实现从数据库加载证书、文件加载证书、缓存加载证书等,具体原理请移动到:SpringBoot https双向认证实现证书热加载
源码和Demo
https://github.com/mzh1994s/spring-boot-hotssl
使用
以下代码来源于github中的Demo项目
添加maven依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>cn.mzhong</groupId>
<artifactId>hotssl-spring-boot-starter</artifactId>
<version>1.0.0</version>
</dependency>
application.yml 添加配置
server:
ssl:
key-store: classpath: