一、生成密钥证书
keytool -genkeypair -alias testkey -keyalg RSA -keypass 123456 -keystore test.keystore -storepass 123456store
keytool是java提供的证书管理工具
-alias: 密钥别名
-keyalg:使用的hash算法
-keypass:密钥的访问密码
-keystore:密钥库文件名,test.keystore保存了生成的证书
-storepass:密钥库的访问密码
查询证书信息:
keytool -list -keystore test.keystore
删除别名
keytool -delete -alias xckey -keystore xc.keystore
二、导出公钥
使用openssl加解密工具导出公钥信息(openssl要配置环境变量)
在密钥文件夹目录下执行如下命令
keytool -list -rfc --keystore test.keystore | openssl x509 -inform pem -pubkey
上面红色部分复制到记事本中,去掉空行,就是公钥了