keytool 是个密钥和证书管理工具。它使用户能够管理自己的公钥/私钥对及相关证书,用于(通过数字签名)自我认证(用户向别的用户/服务认证自己)或数据完整性以及认证服务。在JDK 1.4以后的版本中都包含了这一工具,它的位置为%JAVA_HOME%\bin\keytool.exe
创建证书 生成一个名称为test1的证书 keytool -genkeypair -alias "test1" -keyalg "RSA" -keystore "test.keystore" 查看密钥库里面的证书: 查看test.keystore这个密钥库里面的所有证书 keytool -list -keystore test.keystore 导出到证书文件: 将名为test.keystore的证书库中别名为test1的证书条目导出到证书文件test.crt中 keytool -export -alias test1 -file test.crt -keystore test.keystore 导入证书: 将证书文件test.crt导入到名为test_cacerts的证书库中 keytool -import -keystore test_cacerts -file test.crt 查看证书信息: 查看证书文件test.crt的信息 keytool -printcert -file "test.crt" 删除密钥库中的条目: 删除密钥库test.keystore中别名为test1的证书条目 keytool -delete -keystore test.keystore -alias test1 修改证书条目的口令: 将密钥库test.keystore中别名为test2的证书条目的密码修改为xdp123456 keytool -keypasswd -alias test2 -keystore test.keystore