2011-10-11

java keytool使用方法

导入证书
keytool -import -keystore "%JAVA_HOME%"\jre\lib\security\cacerts -storepass changeit -keypass changeit -alias bocommCA -file root.cer
keytool -import -keystore "%JAVA_HOME%"\jre\lib\security\cacerts -storepass changeit -keypass changeit -alias bocommTestCA -file test_root.cer

删除证书
keytool -delete -alias bocommCA -keystore "%JAVA_HOME%/jre/lib/security/cacerts" -storepass changeit
keytool -delete -alias bocommTestCA -keystore "%JAVA_HOME%/jre/lib/security/cacerts" -storepass changeit

显示证书列表
keytool -list -v -keystore "%JAVA_HOME%"\jre\lib\security\cacerts -storepass changeit
keytool -list -v -alias bocommCA -keystore "%JAVA_HOME%"\jre\lib\security\cacerts -storepass changeit

创建证书
keytool -genkey -alias ligitalsso -dname "CN=portal,OU=huangwq,O=ligital,L=BJ,ST=BJ,C=CN" -keypass changeit -storepass changeit

导出证书
keytool -export -keystore "%JAVA_HOME%"\jre\lib\security\cacerts -alias bocommCA -file d:\temp\bocommCA.cer -storepass changeit
keytool -export -keystore "%JAVA_HOME%"\jre\lib\security\cacerts -alias bocommTestCA -file d:\temp\bocommTestCA.cer -storepass changeit

通过证书文件查看证书的信息
keytool -printcert -file root.cer
keytool -printcert -file test_root.cer

证书条目口令的修改
keytool -keypasswd -keystore "%JAVA_HOME%"\jre\lib\security\cacerts -alias bocommTestCA -keypass 123456 -new aaaaaaa -storepass changeit

修改存储证书的证书库密码(JDK默认存储证书的证书库密码为:changeit)
keytool -storepasswd -keystore "%JAVA_HOME%"\jre\lib\security\cacerts -storepass changeit -new 123456
keytool -storepasswd -keystore "%JAVA_HOME%"\jre\lib\security\cacerts -storepass 123456 -new changeit

没有评论: