Keytool 使用错误的密码创建密钥

Keytool creates key with wrong password

Jetty 不喜欢我的 Java Keystore 的问题归结为这个,我认为:

生成一个新的密钥库(为清楚起见,我包含了密码):

keytool -keystore mark.jks -alias markkey -genkey -keyalg RSA
Enter keystore password: password
Re-enter new password: password
What is your first and last name?
  [Unknown]:  Mark
What is the name of your organizational unit?
  [Unknown]:  MarkProject
What is the name of your organization?
  [Unknown]:  MarkCo
What is the name of your City or Locality?
  [Unknown]:  MarkTown
What is the name of your State or Province?
  [Unknown]:  Markia
What is the two-letter country code for this unit?
  [Unknown]:  UK
Is CN=Mark, OU=MarkProject, O=MarkCo, L=MarkTown, ST=Markia, C=UK correct?
  [no]:  yes
Enter key password for <markkey> password
    (RETURN if same as keystore password):  
Re-enter new password: password

所以我应该有一个密码为 password 的密钥库,其中包含一个密码为 password 的密钥——正确吗? (顺便说一句:如果我按 RETURN 得到 same as keystore password,结果是一样的。)

尝试更改密码:

keytool -keypasswd -new changeit -keystore mark.jks -storepass changeit -alias markkey -keypass password
keytool error: java.io.IOException: Keystore was tampered with, or password was incorrect

怎么会这样?请问我做错了什么或误解了什么?

您的会话记录显示:

keytool -keystore mark.jks -alias markkey -genkey -keyalg RSA
Enter keystore password: password
Re-enter new password: password

但后来你做到了

keytool .... -keystore mark.jks -storepass changeit ....
                                           ^^^^^^^^

它抱怨的是这个不正确的 keystore 密码。