keytool 错误: java.io.IOException: Keystore was tampered with, or password was incorrect → 解决办法

keytool 错误: java.io.IOException: Keystore was tampered with, or password was incorrect → 解决办法

问题复现

我这里是在发布cas时,导入证书到JDK时出错

具体命令行

# 生成证书,用jdk的keytool
keytool -genkey -alias tomcat  -keyalg RSA -keysize 1024 -validity 36500 -keystore /opt/mycas/tomcat.keystore
# 导出证书
keytool -export -trustcacerts -alias tomcat -file /opt/mycas/tomcat.cer -keystore /opt/mycas/tomcat.keystore
# 导入证书到jdk
keytool -import -trustcacerts -alias tomcat -file /opt/mycas/tomcat.cer -keystore "/usr/local/src/java/jdk1.8.0_251/jre/lib/security/cacerts"

于是出现了以下错误
在这里插入图片描述

解决办法

导入证书到JDK输入密钥库口令这里没有输入生成证书时自己设置的秘钥而是输入changeit
或者直接:

keytool -import -trustcacerts -alias tomcat -file /opt/mycas/tomcat.cer -keystore "/usr/local/src/java/jdk1.8.0_251/jre/lib/security/cacerts" -storepass changeit

到这里我的问题解决了,可能每个人出现的问题不一样解决方案也不一样。希望可以帮助到大家。

借鉴文章:https://blog.csdn.net/zhuzhiqiang_zhu/article/details/70212499

猜你喜欢

转载自blog.csdn.net/weixin_42201180/article/details/107628246