Tomcat SSL certificate configuration : java.lang.Exception, Public keys in reply and keystore don't match

huangapple 未分类评论44阅读模式
英文:

Tomcat SSL certificate configuration : java.lang.Exception, Public keys in reply and keystore don't match

问题

我想在我的 Apache Tomcat 中配置 SSL。以下是我所遵循的步骤:
第1步 创建私钥:

keytool -keysize 2048 -genkey -alias tomcat -keyalg RSA -keystore tomcat.keystore
keytool -importkeystore -srckeystore tomcat.keystore -destkeystore tomcat.keystore -deststoretype pkcs12

第2步 创建证书签名请求(CSR):

keytool -certreq -keyalg RSA -alias tomcat -file myFQDN.csr -keystore tomcat.keystore

第2步完成后,将CSR发送给 PKI 授权机构以进行证书生成(在我的情况下是 Globasign)。

第3步 安装来自 Globalsign 的根证书:

keytool -import -alias root -keystore tomcat.keystore -trustcacerts -file gdig2.crt

第4步 安装来自 Globalsign 的中间证书:

keytool -import -alias intermed -keystore tomcat.keystore -trustcacerts -file gd_bundle-g2-g1.crt

第5步 安装证书:

keytool -import -alias tomcat -keystore tomcat.keystore -trustcacerts -file certificate.crt

第5步出现错误:
keytool 错误:java.lang.Exception: 回复中的公钥与密钥库中的公钥不匹配
但是当我更改证书的别名后,它可以成功导入。但由于私钥和证书的别名不相同,SSL 配置无法正常工作。

请帮忙解决。

英文:

I want to configure SSL in my apache Tomcat. Here are the steps are followed :
Step1 Create a private key:

keytool -keysize 2048 -genkey -alias tomcat -keyalg RSA -keystore tomcat.keystore
keytool -importkeystore -srckeystore tomcat.keystore -destkeystore tomcat.keystore -deststoretype pkcs12

Step2 Create a CSR:

keytool -certreq -keyalg RSA -alias tomcat -file myFQDN.csr -keystore tomcat.keystore

After Step 2, the CSR is sent to PKI authority for certificate generation (Globasign in my case).

Step 3 Install the root certificate from Globalsign

keytool -import -alias root -keystore tomcat.keystore -trustcacerts -file gdig2.crt

Step4 Install the intermediate certificate from Globalsign

keytool -import -alias intermed -keystore tomcat.keystore -trustcacerts -file gd_bundle-g2-g1.crt

Step 5 Install the certificate

keytool -import -alias tomcat -keystore tomcat.keystore -trustcacerts -file certificate.crt

Step 5 produces an error :
keytool error: java.lang.Exception: Public keys in reply and keystore don't match
But when I change the alias for certificate, it imports well. But since the private key and certificate do not have the same alias, ssl configuration do not work.

Help please.

huangapple
  • 本文由 发表于 2020年4月7日 18:27:02
  • 转载请务必保留本文链接:https://java.coder-hub.com/61077892.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定