keytool 是个密钥和证书管理工具。它使用户能够管理自己的公钥/私钥对及相关证书,用于(通过数字签名)自我认证(用户向别的用户/服务认证自己)或数据完整性以及认证服务。在JDK 1.4以后的版本中都包含了这一工具,它的位置为%JAVA_HOME%\bin\keytool.exe
创建证书主要是使用" -genkeypair",该命令的可用参数如下:
keytool -genkeypair -alias "test1" -keyalg "RSA" -keystore "test.keystore"
keytool -genkey -keyalg RSA -alias selfsigned -keystore keystore.jks -storepass changeit -validity 360 -keysize 2048
功能:
创建一个别名为test1的证书,该证书存放在名为test.keystore的密钥库中,若test.keystore密钥库不存在则创建。
参数说明:
查看证书
keytool -list -keystore test.keystore
keytool -export -alias test1 -file test.crt -keystore test.keystore
将证书文件test.crt导入到名为test_cacerts的证书库中
keytool -import -keystore test_cacerts -file test.crt
keytool -printcert -file "test.crt"
删除密钥库test.keystore中别名为test1的证书条目
keytool -delete -keystore test.keystore -alias test1
将密钥库test.keystore中别名为test2的证书条目的密码修改为abc123456
keytool -keypasswd -alias test2 -keystore test.keystore
全部评论