证书链未附带服务器证书

时间:2016-04-21 14:11:33

标签: java openssl x509certificate keystore jks

密钥库包含 CA 证书私钥

bash:$ keytool -list -keystore my.keystore 
Enter keystore password:  

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 6 entries

xyz-server-ca, Nov 12, 2015, trustedCertEntry, 
Certificate fingerprint (SHA1): F1:94:1E:B3:C1:E7:7E:54:DA:6B:12:35:26:AA:4C:DE:46:D6:45:3F
xyz-key, Nov 12, 2015, PrivateKeyEntry, 
Certificate fingerprint (SHA1): 81:45:05:29:15:26:0C:0E:71:EB:E0:1F:3E:1C:D8:FE:C6:8D:78:69
xyz-root-ca, Nov 12, 2015, trustedCertEntry, 
Certificate fingerprint (SHA1): 67:D6:A8:37:AD:16:15:31:6D:55:78:02:F2:FA:AB:7A:2A:75:F0:DF
server, Nov 12, 2015, trustedCertEntry, 
Certificate fingerprint (SHA1): 
xyz-root-ca1, Nov 12, 2015, trustedCertEntry, 
Certificate fingerprint (SHA1): 67:D6:A8:37:AD:36:15:31:6D:55:78:02:F2:FA:AB:7A:2A:75:F0:DF
server, Nov 12, 2015, trustedCertEntry, 
Certificate fingerprint (SHA1): 

当我使用openssl查看证书链时,它不会将所有链返回给我,而只是返回服务器证书和一个CA文件

openssl s_client -host 127.0.0.1 -port 443 -prexit -showcerts

---
Certificate chain
 0 s:/C=EU/ST=I/L=Du/O=Inc./OU=Foot/CN=example.com
   i:/C= EU/O=I/OU=Du/CN=Servers CA

1 个答案:

答案 0 :(得分:0)

这是预期的行为。进行SSL握手时,服务器将使用自己的SSL证书和链中的所有CA证书进行响应 *除根证书* 。来自RFC 5246 §7.4.2的参考:

  

certificate_list         这是证书的序列(链)。发件人的         证书必须在列表中排在第一位。以下各项         证书必须直接证明其前面的证书。因为         证书验证要求分发根密钥         独立地,指定根的自签名证书         证书颁发机构可以从链中省略         假设远程端必须已经拥有它以便         无论如何都要验证它。

换句话说,在SSL协商期间不发送root(以自签名形式呈现)证书是一种好习惯。