1、生成.keystore
keytool -genkeypair -alias cas -keyalg RSA -storepass changeit
2、默认情况下,生成的 keystore 就是用户目录下的 .keystore 文件。
3、提示“您的名字与姓氏是什么?”,这里需要输入一个域名,例如:www.xxx.com,本例中输入 cas 需要在 hosts 文件中做如下映射:127.0.0.1 cas
2、查看 keypair:
keytool -list -storepass changeit
3从 keystore 中导出证书
生成的证书文件为 cas.crt,位于运行该命令所在的当前目录下。
可双击该证书文件,将该证书安装到“受信任的根证书颁发机构”中,这样在浏览器中使用 HTTPS 协议访问时才不会出现一个红色的叉叉。
keytool -exportcert -alias cas -file cas.crt -storepass changeit
4导入证书到 JVM 中
使用以下命令导入证书到 JVM 的 keystore 中: