一、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