是否可以单独通过 application.yml 配置来完成此任务?我正在运行 Spring Boot v3.1.4。
我已经使用 win-acme 创建了一个 SSL 证书,并且正在尝试将其部署在我的 Spring Boot 应用程序中。我已经让它使用不受密码保护的私钥,但我想使用密码对其进行加密以增强安全性。我的新证书和私钥已配置,并且我已设置 application.yml,但它告诉我 RSA 格式无法识别。
Caused by: java.lang.IllegalStateException: Error loading private key file: Unrecognized private key format
at org.springframework.boot.ssl.pem.PemPrivateKeyParser.parse(PemPrivateKeyParser.java:200)
at org.springframework.boot.ssl.pem.PemSslStoreBundle.createKeyStore(PemSslStoreBundle.java:92)
... 24 common frames omitted
Caused by: java.lang.IllegalStateException: Unrecognized private key format
at org.springframework.boot.ssl.pem.PemPrivateKeyParser.parse(PemPrivateKeyParser.java:197)
... 25 common frames omitted
这是我的应用程序.yml:
server:
port: ${PORT}
ssl:
certificate: C:\cert\crt.pem
certificate-private-key: C:\cert\key.pem
key-store-password: 1234567890
这是我的私钥的前几行:
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC
SSL Bundles 功能支持受密码保护的私钥。配置捆绑包,包括 private-key-password
属性,然后将该捆绑包应用到您的 Web 服务器。
spring:
ssl:
bundle:
pem:
server:
keystore:
certificate: C:\cert\crt.pem
private-key: C:\cert\key.pem
private-key-password: 1234567890
server:
port: ${PORT}
ssl:
bundle: "server"