原文地址:http://www.micmiu.com/lang/java/keytool-start-guide/
Keytool 是一个Java数据证书的管理工具 ,Keytool将密钥(key)和证书(certificates)存在一个称为keystore的文件中在keystore里,包含两种数据:密钥实体(Key entity)-密钥(secret key)或者是私钥和配对公钥(采用非对称加密)可信任的证书实体(trusted certificate entries)-只包含公钥.
JDK中keytool常用参数说明(不同版本有差异,详细可参见【附录】中的官方文档链接):
目录说明:
keytool -genkey -alias michaelkey -keyalg RSA -keysize 1024 -keypass michaelpwd -validity 365 -keystore g:\sso\michael.keystore -storepass michaelpwd2
截图如下:
二、查看证书
缺省情况下,-list 命令打印证书的 MD5 指纹。而如果指定了 -v 选项,将以可读格式打印证书,如果指定了 -rfc 选项,将以可打印的编码格式输出证书。
keytool -list -v -keystore g:\sso\michael.keystore -storepass michaelpwd2
回车看到的信息如下:
-rfc 命令如下:
keytool -list -rfc -keystore g:\sso\michael.keystore -storepass michaelpwd2
回车看到的信息如下:
三、证书的导出和查看:
keytool -export -alias michaelkey -keystore g:\sso\michael.keystore -file g:\sso\michael.crt -storepass michaelpwd2
回车如下:
查看导出的证书信息:
keytool -printcert -file g:\sso\michael.crt
回车看到信息如下:
四:附录
原文:http://www.cnblogs.com/yuanyee/p/6339670.html