1.生成 keystore
[root@test conf]# keytool -genkey -v -alias tomcat -keyalg RSA -keystore mykeystore
Enter keystore password: #设置密码
Re-enter new password: #重复一次
What is your first and last name?
[Unknown]: Alex Lu #随便填
What is the name of your organizational unit?
[Unknown]: visionet #随便填
What is the name of your organization?
[Unknown]: visionet #随便填
What is the name of your City or Locality?
[Unknown]: SH #随便填
What is the name of your State or Province?
[Unknown]: SH #随便填
What is the two-letter country code for this unit?
[Unknown]: ZH #随便填
Is CN=Alex Lu, OU=visionet, O=visionet, L=SH, ST=SH, C=ZH correct?
[no]: Y #这里要Y,确认前面信息。
Generating 2,048 bit RSA key pair and self-signed certificate (SHA256withRSA) with a validity of 90 days
for: CN=Alex Lu, OU=visionet, O=visionet, L=SH, ST=SH, C=ZH
Enter key password for
(RETURN if same as keystore password): #默认回车即可,不需要设置太多密码
[Storing mykeystore]
[root@test conf]# ls
Catalina catalina.policy catalina.properties context.xml logging.properties mykeystore server.xml tomcat-users.xml web.xml 注意:-keystore是用来指定keystore保存位置,如果不加参数默认保存的当前用户家目录为~/.keystore
-validity 可以用来指定证书有效期,单位为天,缺省值为90天。