gpt4 book ai didi

keytool - 如何使用 keytool 更改 PKCS12 keystore 密码?

转载 作者:行者123 更新时间:2023-12-02 06:58:22 27 4
gpt4 key购买 nike

我无法使用 keytool (java 8) 更改 PKCS keystore 密码。当我尝试更改 key 密码时:

keytool -keypasswd -keystore keystore.p12 -storetype PKCS12 -storepass oldpass -keypass oldpass -new newpass
keytool error: java.lang.UnsupportedOperationException: -keypasswd commands not supported if -storetype is PKCS12

这意味着 PKCS12 keystore 的 key 密码无法更改。然后我尝试更改 keystore 密码:

keytool -storepasswd -keystore keystore.p12 -storetype PKCS12 -storepass oldpass -new newpass
Warning: Different store and key passwords not supported for PKCS12 KeyStores. Ignoring user-specified -new value.
keytool error: java.io.FileNotFoundException: keystore.p12 (Access is denied)

这意味着,我们必须一起更改 keystore 密码和 key 密码。但没有命令可以同时更改两者。我能做什么?

最佳答案

您可以将 PKCS12 文件导入到另一个 PKCS12,您可以在其中为新 PKCS12 文件提供新密码。然后您可以使用新的 PKCS12 文件或删除以前的文件并用旧文件名重命名新文件名。这不是一个直接的方法,但它实现了目标。下面给出了示例代码

keytool -importkeystore -srckeystore DocCA.p12 -srcstoretype PKCS12 -srcstorepass 123456 -destkeystore DocCA2.p12 -deststoretype PKCS12 -deststorepass 11223344 

此处,DocCA.p12 是密码为 123456 的现有 PKCS12,导出到 DocCA2.p12 文件中,密码为 11223344。

关于keytool - 如何使用 keytool 更改 PKCS12 keystore 密码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31228462/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com