1、生成密钥证书 下边命令生成密钥证书,采用RSA 算法每个证书包含公钥和私钥
keytool -genkeypair -alias testkey -keyalg RSA -keypass keypassword -keystore test.keystore -storepass keystorypassword
-alias:密钥的别名
-keyalg:使用的hash算法
-keypass:密钥的访问密码
-keystore:密钥库文件名,xc.keystore保存了生成的证书
-storepass:密钥库的访问密码
查询证书信息:
keytool -list -keystore test.keystore
2、导出公钥
openssl是一个加解密工具包,这里使用openssl来导出公钥信息。
安装 openssl:http://slproweb.com/products/Win32OpenSSL.html
配置openssl的path环境变量
也可以使用linux安装的openssl工具,效果相同
cmd进入keystore文件所在目录执行如下命令:
keytool ‐list ‐rfc ‐‐keystore test.keystore | openssl x509 ‐inform pem ‐pubkey
输入密钥库密码后,会得到下图公钥,私钥信息