一、Centos安装Certbot客户端
bash
yum install certbot
二、生成证书
bash
certbot certonly --standalone -d 你的域名
执行该命令后会生成如下文件
privkey.pem
: the private key for your certificate.
fullchain.pem
: the certificate file used in most server software.
chain.pem
: used for OCSP stapling in Nginx >=1.3.7.
cert.pem
: will break many server configurations, and should not be used without reading further documentation (see link below).
三、生成pfx文件
bash
openssl pkcs12 -export -inkey privkey.pem -in cert.pem -certfile chain.pem -out 你的域名.pfx -legacy -name tomcat -passout pass:你的密码
四、配置SpringBoot的pom文件
java
server:
#port: 80 #8091
tomcat:
uri-encoding: UTF-8
http:
encoding:
charset: UTF-8
servlet:
context-path:
encoding:
charset: UTF-8
session:
timeout: 60d # 设置 Session 60 天后过期
port: 443
ssl:
key-store: classpath:你的域名.pfx #pfx 具体的路径
key-store-type: PKCS12
key-store-password: 你的密码 #密码内容
key-alias: tomcat
五、打包SpringBoot项目为jar文件
六、服务器执行jar文件
bash
java -jar 你的项目名称.jar