使用centos服务器和Let‘s Encypted配置SpingBoot项目的https证书
一、Centos安装Certbot客户端
yum install certbot
二、生成证书
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文件
openssl pkcs12 -export -inkey privkey.pem -in cert.pem -certfile chain.pem -out 你的域名.pfx -legacy -name tomcat -passout pass:你的密码
四、配置SpringBoot的pom文件
server:#port: 80 #8091tomcat:uri-encoding: UTF-8http:encoding:charset: UTF-8servlet:context-path: encoding:charset: UTF-8session:timeout: 60d # 设置 Session 60 天后过期port: 443ssl:key-store: classpath:你的域名.pfx #pfx 具体的路径key-store-type: PKCS12key-store-password: 你的密码 #密码内容key-alias: tomcat
五、打包SpringBoot项目为jar文件
六、服务器执行jar文件
java -jar 你的项目名称.jar