gpt4 book ai didi

java - 在 Java cacerts 中导入根证书和中间证书的正确方法

转载 作者:太空宇宙 更新时间:2023-11-03 13:15:29 30 4
gpt4 key购买 nike

我的公司有自己的 ROOT 证书。他们使用此证书签署了中间 证书。

然后我们为server证书签发CSR,并用intermediate证书签名。

在 Java cacerts 文件中导入 ROOT 证书和 intermediate 的正确方法是什么,以便能够与具有 的服务器建立 SSL 连接>server中间签署的证书?

我使用 OpenSSL 在服务器上测试证书链:

openssl s_client -showcerts -connect host:443

CONNECTED(00000003)
depth=0 C = COUNTRYCODE, ST = myCountry, O = myOrganization, CN = myServer, emailAddress = myMail
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=0 C = COUNTRYCODE, ST = myCountry, O = myOrganization, CN = myServer, emailAddress = myMail
verify error:num=27:certificate not trusted
verify return:1
depth=0 C = COUNTRYCODE, ST = myCountry, O = myOrganization, CN = myServer, emailAddress = myMail
verify error:num=21:unable to verify the first certificate
verify return:1
---
Certificate chain
0 s:/C=COUNTRYCODE/ST=myCountry/O=myOrganization/CN=myServer/emailAddress=myMail
i:/CN=INTERMEDIATECERT
-----BEGIN CERTIFICATE-----
MIIFr...
-----END CERTIFICATE-----
---
Server certificate
subject=/C=COUNTRYCODE/ST=myCountry/O=myOrganization/CN=myServer/emailAddress=myMail
issuer=/CN=INTERMEDIATECERT
---
No client certificate CA names sent
---
SSL handshake has read 1601 bytes and written 589 bytes
---
New, TLSv1/SSLv3, Cipher is AES256-SHA

最佳答案

您只需要在信任库中导入根证书。

 keytool -import -trustcacerts -keystore path/to/cacerts -storepass changeit  -alias aliasName -file path/to/certificate.cer

握手期间的 SSL 服务器应提供证书和中间体。您的客户的 TrustManager 将验证证书链,直到找到根为止

注意:建议使用自己的truststore而不是修改cacerts

关于java - 在 Java cacerts 中导入根证书和中间证书的正确方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42027922/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com