首页 > java > keytool用法总结

keytool用法总结

2013年8月29日 亲亲宝宝 发表评论 阅读评论

SUN公司提供了制作证书的工具keytool,  在JDK 1.4以后的版本中都包含了这一工具,它的位置为<JAVA_HOME>\bin\keytool.exe。

keytool的几个常用的命令。
1.创建证书
2.查看证书库
3.导出证书文件
4.导入证书的信息
5.查看证书信息
6.删除密钥库中的条目
7.修改证书条目的口令

1.创建证书
keytool -genkeypair -alias “test1” -keyalg “RSA” -keystore “test.keystore”

说明:
密钥库密码为testtest
证书条目密码为testtest1,若别名为test2则密码为testtest2
这样为个不乱
功能:
创建一个别名为test1的证书条目,该条目存放在名为test.keystore的密钥库中,若test.keystore密钥库不存在则创建。
参数说明:
-genkeypair:生成一对非对称密钥;
-alias:指定密钥对的别名,该别名是公开的;
-keyalg:指定加密算法,本例中的采用通用的RAS加密算法;
-keystore:密钥库的路径及名称,不指定的话,默认在操作系统的用户目录下生成一个”.keystore”的文件

2.查看证书库
keytool -list -keystore test.keystore

3.导出到证书文件
keytool -export -alias test1 -file test.crt -keystore test.keystore
将名为test.keystore的证书库中别名为test1的证书条目导出到证书文件test.crt中

4.导入证书的信息
keytool -import -keystore test_cacerts -file test.crt

5.查看证书信息
keytool -printcert -file “test.crt”

6.删除密钥库中的条目
删除密钥库test.keystore中别名为test2的证书条目
keytool -delete -keystore test.keystore -alias test2

7.修改证书条目的口令
keytool -keypasswd -alias test1 -keypass testtesttest1 -new testtest1 -storepass testtest -keystore test.keystore
功能:
将密钥库test.keystore中别名为test1的证书条目的密码修改为testtest1

 

分类: java 标签: 3,258 次阅读
原文链接:http://www.wenhq.com/article/view_785.html
欢迎转载,请注明出处:亲亲宝宝
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.