使用pem和key文件给springboot开启https服务
操作步骤
1. 将两个文件整合为springboot支持的p12文件
openssl pkcs12 -export -out G:\\rrr\\server.p12 -in G:\\rrr\\aaa.com.pem -inkey G:\\jftest\\aaa.com.key -name aaa
回车后输入密码:123456
2. 设置springboot:
server:port: 8088ssl:key-store: classpath:server.p12 # .p12 文件在 resources 目录下的路径key-store-type: PKCS12 # 密钥库类型(固定为 PKCS12)key-store-password: 123456 # 步骤 2 中设置的密钥库密码key-alias: aaa # 步骤 2 中设置的别名key-password: 123456 # 私钥密码(若与密钥库密码相同,可省略)
3. 测试:
https://localhost:8088/test/hello
tips
查看域名:
openssl x509 -in G:\\rrr\\aaa.com.pem -noout -text