KSS*_*KSS 6 java explorer keystore jks spring-boot
我创建了一个全局 JKS,其密钥库密码为“changeme”。我使用 Keystore Explorer 创建了 JKS。
使用全局 JKS 背后的想法是应用程序可以从 S3 中拉取 JKS,然后使用自己的字符串密码重置 JKS。我们使用了很多 SpringBoot API,并使用 JKS 来保护容器中的 Tomcat,以便我们可以连接 HTTPS。
但这是我遇到的问题,当我更改 JKS 密钥库密码时,我开始抛出java.security.UnrecoverableKeyException: Cannot recover key错误。
在密钥库资源管理器中,我没有为别名指定密码。当我进入密钥库资源管理器更改别名密码时,它接受“changeme”作为密码。因此,我假设密钥库资源管理器会自动使用 Changeme 作为密码,因为我为 JKS 密钥库密码提供了它。
诚然,我不是使用 JKS 和了解安全性复杂性的专家,但这让我难住了。
我还尝试使用以下命令使用 Keytool 更改密钥库密码:
keytool -storepasswd -keystore myJKS.jks
Run Code Online (Sandbox Code Playgroud)
和
keytool -keypasswd -alias myalias -keystore myJKS.jks
Run Code Online (Sandbox Code Playgroud)
但是当我尝试更改别名时,我得到:
keytool错误:java.io.IOException:密钥库被篡改,或密码不正确
我究竟做错了什么?
谢谢
您看到的错误是因为您可能keystore-password在命令中提供了错误。
对如何以及是什么有基本的了解JKS。JKS(Java KeyStore)基本上是一个保护密钥(对称密钥)、密钥对(非对称密钥)和证书的文件。它保护它们的方式是通过密码,该密码称为keystore-password. JKS 文件中的密钥也可以单独保护,这意味着它们可以有自己的密码,称为key-password.
修改keystore密码的方法:
keytool -storepasswd -keystore [KEYSTORE] -storepass [OLD_KEYSTORE_PASSWORD] -new [NEW_KEYSTORE_PASSWORD]
修改密钥密码的方法:
keytool -keypasswd -keystore [KEYSTORE] -storepass [KEYSTORE_PASSWORD] -alias [ALIAS] -keypass [OLD_KEY_PASSWORD] -new [NEW_KEY_PASSWORD]
这些是与保护 spring-boot 应用程序相关的属性。您必须在这些属性中定义密钥库密码和密钥密码。
server.ssl.ciphers= # Supported SSL ciphers.
server.ssl.client-auth= # Client authentication mode.
server.ssl.enabled=true # Whether to enable SSL support.
server.ssl.enabled-protocols= # Enabled SSL protocols.
server.ssl.key-alias= # Alias that identifies the key in the key store.
server.ssl.key-password= # Password used to access the key in the key store.
server.ssl.key-store= # Path to the key store that holds the SSL certificate (typically a jks file).
server.ssl.key-store-password= # Password used to access the key store.
server.ssl.key-store-provider= # Provider for the key store.
server.ssl.key-store-type= # Type of the key store.
server.ssl.protocol=TLS # SSL protocol to use.
server.ssl.trust-store= # Trust store that holds SSL certificates.
server.ssl.trust-store-password= # Password used to access the trust store.
server.ssl.trust-store-provider= # Provider for the trust store.
server.ssl.trust-store-type= # Type of the trust store.
Run Code Online (Sandbox Code Playgroud)
您可以在此处的文档中找到所有 spring-boot 属性。
如果你看一下属性,就会发现有server.ssl.key-store-password和server.ssl.key-password。您可以要求用户在更改全局 JKS 密码后设置这两个值。
| 归档时间: |
|
| 查看次数: |
14830 次 |
| 最近记录: |