1.生成keystore文件
keytool -genkey -alias jetty -keyalg RSA -keysize 2048 -keystore mykeystore
1)Enter keystore password:
输入密码,在之后要使用,须谨记
Re-enter new password:
确认密码
2)What is your first and last name?
输入域名
3)What is the name of your organizational unit?
输入组织单位名称
4)What is the name of your organization?
输入组织名称
5)What is the name of your City or Locality?
输入您所在城市或区域的名称,如:Shanghai
6)What is the name of your State or Province?
输入您所在州或省份的名称,如:Shanghai
7) What is the two-letter country code for this unit?
输入单位的两字母国家代码,一般是CN
8)然后会有一个确认信息,输入Y<Enter>
9)Enter key password for <jetty>
(RETURN if same as keystore password)
直接按<Enter>
2.生成csr文件
keytool -certreq -alias jetty -keystore mykeystore -file centreq.csr
3.提交证书验证机构,获取中级证书和服务器证书
中级证书和服务器证书是一段字符集,拷贝到文本,分别保存文件名为zhongji.cer和server.cer
4.导入中级证书
keytool -import -trustcacerts -keystore mykeystore -alias zhongji -file zhongji.cer
5.导入服务器证书
keytool -import -trustcacerts -keystore mykeystore -alias jetty -file server.cer
注意:
导入服务器证书的别名与生成keystore文件的别名一致
附:删除证书:keytool -delete -alias jetty -keystore server.jks (别名与证书别名一致)
查看证书:keytool -list -v -keystore server.jks