我在将证书文件导入 keystore 时遇到了这个问题:
keytool error: java.lang.Exception: Public keys in reply and keystore don't match
我做这个操作:
1) 在服务器上创建我的 keystore :
keytool -genkey -keystore C:\keystore\keystore -alias jboss -keyalg RSA
2) 我有 domain.pfx 并使用此命令将其转换:
openssl pkcs12 -in domain.pfx -clcerts -nokeys -out domain.cer
openssl pkcs12 -in domain.pfx -nocerts -nodes -out domain_encrypted.key
openssl rsa -in domain_encrypted.key -out domain.key
现在我有 3 个新文件:
- 域名.cer
- domain_encrypted.key
- 域名.key
3) 最后,将domain.cer导入jboss别名中的C:\keystore\keystore:
keytool -import -alias jboss -keystore C:\keystore\keystore -file C:\cert\domain.cer
但是我有这个错误:
keytool error: java.lang.Exception: Public keys in reply and keystore don't match
问题是什么?
最佳答案
keystore 由两种条目类型组成:
私钥条目(将存储在 keystore 中的私钥与导入到 keystore 中的证书绑定(bind)。)这里,别名必须与创建 keystore 文件时使用的别名保持一致。
可信条目:- 此条目包含所有可信证书条目,包括根证书和中间证书。
如果 keystore 绑定(bind)到 tomcat 的 server.xml
文件中的域,那么它必须包含私钥条目。
现在,根据您执行的步骤,您首先创建了一个 keystore (其中生成了一个私钥),然后您尝试在 keystore 中导入证书。但是在命令中你没有使用你使用 openssl
转换的私钥;您使用了生成 keystore 时新生成的私钥。
因为你有domain.pfx
,你可以直接使用下面的keytool
命令转换它:
keytool -importkeystore -srckeystore domain.pfx -srcstoretype pkcs12 -destkeystore name_of_the_keystore_file.jks -deststoretype jks
注意:确保 keystore 密码和 key 密码保持不变。
关于ssl - keytool 错误 : java. lang.Exception:回复中的公钥和 keystore 不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26256856/