如何使用keytool更改PKCS12密钥库密码? [英] how to change PKCS12 keystore password using keytool?

查看:1362
本文介绍了如何使用keytool更改PKCS12密钥库密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用keytool(java 8)更改PKCS密钥库密码.当我尝试更改密钥密码时:

I cannot change PKCS keystore password using keytool (java 8). When I tried to change the key password:

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密钥库的密钥密码.然后我尝试更改密钥库密码:

It means key password cannot be changed for PKCS12 keystore. Then I tried to change the keystore password:

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)

这意味着,我们必须一起更改密钥库密码和密钥密码.但是没有命令可以同时更改两者.我该怎么办?

It means, we have to change keystore password and keypassword together. But there is no command to change both. What can I do?

推荐答案

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

You can import the PKCS12 file to another PKCS12 where you can give new password for new PKCS12 file. Then you can use the new PKCS12 file or delete the previous one and rename the new file name with the old file name. Its not a straight forward way, but it fulfills the objective.A sample code is given bewlow

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

在这里,DoCA.p12是密码为123456的现有PKCS12,已导出到密码为11223344的DocCA2.p12文件中.

Here, DoCA.p12 is the existing PKCS12 with password 123456 which is exported in the DocCA2.p12 file with password 11223344.

这篇关于如何使用keytool更改PKCS12密钥库密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆