目录
基于上一篇文章生成的证书:Nginx-配置HTTPS证书(单向认证)_孟孟的博客-CSDN博客_nginx配置https访问
一、证书转换
- 服务方给的证书多为"cer"类型,比如直接从浏览器中下载下来的,该类证书不能直接使用java调用认证,需转换为java可识别的类型,比如".keystore"。
- 利用jdk中"keytool"命令进行转换,即证书导入,执行命令:
keytool -importcert -keystore client.keystore -file nginx.crt
二、引入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version

本文介绍了如何将cer类型的证书转换为keystore格式,并在Spring Boot中配置RestTemplate进行HTTPS证书认证,包括引入相关依赖,配置SSLContext和RestTemplate,以及在Service层使用sslRestTemplate进行安全的HTTP请求。
4217

被折叠的 条评论
为什么被折叠?



