[TOC]
SpringBoot配置https访问 (使用p12证书)
需求清单
- 云服务器ECS
- 域名
- SSL证书
步骤
去阿里云官网后台下载SSL证书

因为使用p12配置https访问,这里选择的Nginx类型证书下载

解压证书

登录云服务
通过终端使用 ssh 登录服务器
新建文件夹,用来存放证书相关
mkdir -p /root/cer
拷贝
crt
和key
文件
使用scp
命令把本地电脑上的证书文件(crt
和 key
文件)拷贝到服务器的文件夹下(/root/cer
):
scp -r 本地电脑.crt文件路径 root@112.112.11.11:/root/cer
在云服务器上执行命令生产
server.p12
文件
openssl pkcs12 -export -clcerts -in xxx.crt -inkey xxx.key -out server.p12

把服务器上生成的
server.p12
证书下载到自己电脑上
命令仍然是 scp
把下载下来的证书添加到项目中,位置在
resources
目录下

在
.properties
文件中配置 ssl 访问

使用https访问

把应用发布到服务器上进行访问

网友评论