采用RSA算法每个证书包含公钥和私钥,使用以下命令可以生成秘钥证书:
keytool -genkeypair -alias crkey -keyalg RSA -keypass classroom -keystore cr.keystore -storepass classroomkeystore
keytool 是一个java提供的证书管理工具
-alias: 密钥的别名
-keyalg: 使用的hash算法
-keypass: 密钥的访问密码
-keystore: 密钥文件名,该文件保存了生成的证书
-storepass:密钥库的访问密码
查询证书信息:
keytool -list -keystore cr.keystore
删除别名
keytool -delete -alias crkey -keystore rc.keystore
导出公钥:
openssl是一个加解密工具包,这里使用openssl来导出公钥信息。
安装openssl: http://slproweb.com/products/Win32OpenSSL.html
配置openssl的path环境变量,cmd进入rc.keystore文件所在目录执行如下命令:
keytool -list -rfc --keystore cr.keystore | openssl x509 -inform pem -pubkey
然后输入密钥库密码:
public key那部分就是公钥。