keytool : 证书导入给出错误消息 - 密钥库被篡改或密码不正确

2022-01-25 00:00:00 certificate keystore java keytool

我的目标是生成证书,将其导出到文件中并导入 JDK 密钥库.

在第一步中,我使用以下命令生成了一个自签名证书,为密钥库和密钥提供密码作为密码":

In first step I have generated a self signed certificate using following command, providing password as 'password' for keystore and key:

keytool   -genkeypair  -keystore .keystore  -alias uasera  -keyalg RSA

在第二步中,我使用类似的密码和以下命令导出了证书:

In second step I exported the certificate using similar password and following command:

keytool  -exportcert  -keystore  .keystore  -alias usera  -file usera.crt

现在!

我正在尝试使用类似的密码和以下命令在 JDK 的 cacerts 中导入此证书,但出现异常.

I am trying to import this certificate in cacerts in JDK using similar password and following command but getting exception.

keytool -importcert -file usera.crt -keypass password  -keystore "C:Program FilesJavajdk1.7.0_13jrelibsecuritycacerts"

错误

K:javacertificates>keytool -importcert -file usera.crt -keypass password -keystore "C:Program FilesJavajdk1.7.0_13jrelibsecuritycacerts"输入密钥库密码:keytool error: java.io.IOException: Keystore was tampered, or password is wrong

K:javacertificates>keytool -importcert -file usera.crt -keypass password -keystore "C:Program FilesJavajdk1.7.0_13jrelibsecuritycacerts" Enter keystore password: keytool error: java.io.IOException: Keystore was tampered with, or password was incorrect

推荐答案

我已经解决了这个问题.我使用我的密码password"来更新 JDK 中的 cacerts 密钥库,而 cacerts 密钥库的默认密码是changeit"

I have got this sorted out. I was using my password that is 'password' to update cacerts keystore in JDK while default password for cacerts keystore is 'changeit'

相关文章