我公司有自己的ROOT
证书。使用此证书,他们签署了intermediate
证书。
然后我们为server
证书颁发了CSR,并使用intermediate
证书进行了签名。
在Java cacerts文件中导入ROOT
证书和intermediate
的正确方法是什么,以便能够与具有server
证书签名的服务器建立SSL连接intermediate
?
我使用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
答案 0 :(得分:2)
您只需要在信任库中导入根证书。
keytool -import -trustcacerts -keystore path/to/cacerts -storepass changeit -alias aliasName -file path/to/certificate.cer
握手期间的SSL服务器应提供证书和中间人。您的客户的TrustManager将验证证书链,直到找到root
注意:建议使用您自己的信任库而不是修改cacerts