【问题标题】:The destination pkcs12 keystore has different storepass and keypass. Please retry with -destkeypass specified目标 pkcs12 密钥库具有不同的 storepass 和 keypass。请使用指定的 -destkeypass 重试
【发布时间】:2020-06-09 16:33:44
【问题描述】:

我是密钥生成的新手。当我跟进这些步骤时,我收到如下错误...

D:\My_Personal_Projects\springblog>keytool -importkeystore -srckeystore springblog.jks -destkeystore springblog.jks -deststoretype pkcs12"
Enter source keystore password:
Enter key password for <springblog>
keytool error: java.lang.Exception: The destination pkcs12 keystore has different storepass and keypass. Please retry with -destkeypass specified.

以下是我经历的步骤

D:\My_Personal_Projects\springblogfrontend>cd springblogfrontend

D:\My_Personal_Projects\springblogfrontend\springblogfrontend>keytool -genkey -alias springblog -keyalg RSA --keystore springblog.jks 
-keysize 2048
Enter keystore password:  
Re-enter new password: 
What is your first and last name?
  [Unknown]:  Niroshan
What is the name of your organizational unit?
  [Unknown]:  springblog
What is the name of your organization?
  [Unknown]:
What is the name of your City or Locality?
  [Unknown]:
What is the name of your State or Province?
  [Unknown]:
What is the two-letter country code for this unit?
  [Unknown]:  

Is CN=Niroshan, OU=springblog, O=Unknown, L=Unknown, ST=Unknown, C=Unknown correct?
  [no]:  yes

Enter key password for <springblog>
        (RETURN if same as keystore password):
Re-enter new password:

Warning:
The JKS keystore uses a proprietary format. It is recommended to migrate to PKCS12 which is an industry standard format using "keytool -importkeystore -srckeystore springblog.jks -destkeystore springblog.jks -deststoretype pkcs12".

D:\My_Personal_Projects\springblogfrontend\springblogfrontend>keytool -importkeystore -srckeystore springblog.jks -destkeystore springblog.jks -deststoretype pkcs12
Enter source keystore password:
Enter key password for <springblog>
keytool error: java.lang.Exception: The destination pkcs12 keystore has different storepass and keypass. Please retry with -destkeypass specified.

是什么导致了这个错误?非常感谢任何帮助

【问题讨论】:

  • 为什么将 PKCXS#12 密钥库命名为 *.jks?不要那样做。
  • @user207421:显然是因为 keytool 警告(在 8usomething 和 9.0.1 中)说,虽然我同意这不是一个好主意。 OP:您使用的是哪种 Java? AFAIK only j8 默认情况下都会创建 jks 并发出警告,但在我有 -importkeystore 的版本中,两次提示输入目标存储密码,源密码之前。
  • 我实际上对此很陌生。这是我的第一代密钥。我能知道这个密钥生成 user207421 dave_thompson_085 背后的想法吗?我也还没想出解决办法。

标签: java spring-boot authentication jwt keystore


【解决方案1】:

发生此错误是因为您的密钥库中有两个不同的密码。第一个是密钥库密码(或 storepass),请查看以下几行:

Enter keystore password:
Re-enter new password:

第二个是您的别名的密钥密码(或keypass),keytool 在密钥库生成结束时要求输入此密码,请查看以下几行:

Enter key password for <springblog>
        (RETURN if same as keystore password):
Re-enter new password:

这里有两个解决keytool错误问题的选项:

  1. 当 keytool 要求 keypass 时,只需按建议按 RETURN,然后keytool -importkeystore -srckeystore springblog.jks -destkeystore springblog.jks -deststoretype pkcs12 将按预期工作,没有任何错误。
  2. 在执行上述迁移/导入命令时,在您的密钥密码(别名的密码)中添加-destkeypass 选项。在这种情况下,keytool 会向您发出警告 Warning: Different store and key passwords not supported for PKCS12 KeyStores. Ignoring user-specified -destkeypass value.,但会成功完成导入。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-19
    • 2021-08-23
    • 1970-01-01
    • 2014-01-04
    • 2011-09-03
    • 2011-08-22
    • 1970-01-01
    相关资源
    最近更新 更多