Java SSLSocket: How to send full server cert chain?

三世轮回 提交于 2019-12-31 02:40:28

问题


When I create an SSLServerSocket in Java 7 the server correctly uses my server certificate and key. The certificate was issued by a sub-ca of a ca. Therefore the complete chain from the root cert to the server cert has four certificates. The complete chain is present in the keystore/truststore.

However when a client connects the server always sends only the server certificate itself. This also applies to Java based web servers like Jetty.

Because most clients have only the root ca certificate installed and not the two sub-ca certificates this is a big problem.

How can I force Java to send the full certificate chain in the SSL/TLS handshake?


回答1:


A key entry in a keystore isn't just for a single certificate, but for a certificate chain (see KeyStore.setKeyEntry, which takes a Certificate[] chain parameter).

If you want a specific chain to be used, it needs to be set up as a chain in the entry where you have the certificate and its private key. Whether the intermediate certificates are also in the same keystore, in different entries doesn't really matter.

This is a very similar problem to getting a client to send the full client-certificate chain. The same keystore configuration steps should also work from a server point of view, as described in this question.



来源:https://stackoverflow.com/questions/12778012/java-sslsocket-how-to-send-full-server-cert-chain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!