我使用以下命令为我的Web应用程序生成jks.
keytool -genkey -keyalg RSA -alias my-app -validity 10800 -keysize 2048 -sigalg SHA1withRSA -keystore myapp.jks
此命令提示如下问题:
Enter keystore password:
Re-enter new password:
What is your first and last name?
[Unknown]: GS
What is the name of your organizational unit?
[Unknown]: XX
What is the name of your organization?
[Unknown]: YY
What is the name of your City or Locality?
[Unknown]: ZZ
What is the name of your State or Province?
[Unknown]: AA
What is the two-letter country code for this unit?
[Unknown]: BB
Is CN=GS, OU=XX, O=YY, L=ZZ, ST=AA, C=BB correct?
[no]: yes
Enter key password for <my-app> //Why this password is required???
(RETURN if same as keystore password):
只有当密钥库密码[首次提示]和密钥密码时,Tomcat才能读取此密钥库.当我使用其他密码代替“密钥密码”时,由于密钥库文件,tomcat无法启动.
我的问题是密钥密码的意义是什么.
P.S:我看过这个link.他们在这里说:
Press RETURN when prompted for the key password (this action makes the key password the same as the KeyStore password).
如果两个密码必须相同,那么任何想法询问它两次的意义是什么?
解决方法:
正如JavaDoc所述
The keypass value that you are prompted for specifies a password for
the private key about to be generated. You will always need this
password in order to access the keystore entry containing that key.
The entry doesn’t have to have its own password. When you are prompted
for the key password, you are given the option of letting it be the
same as the keystore password.
密钥库可以包含多个密钥,每个密钥只能使用密码访问.因此,如果您希望将密钥密码与您正在创建的密钥库保持一致,则keytool只是为您提供一个选项.