Force Chrome to send all certificates in chain during TLS

痞子三分冷 提交于 2019-12-24 08:17:06

问题


I have written a TLS code which is doing mutual authentication at Java, so client is sending its certificate after server sends its certificate. I would like to validate all the certificates in certificate chain by OCSP which is coming from client side to server side.

I have written my loop logic as assuming that last certificate is root(CA) certificate in the chain and not to send any OCSP query for it;

        int certificateChainSize= x509Certificates.length;

        // Verifies certificate chain respectively (issuer certificate required).
        CertificateResult response = null;

        try {
            for (int i = 0; i < certificateChainSize-1 ; i++) {
                response = client.verify(x509Certificates[i], x509Certificates[i+1]);
            }
        } catch (OcspException e) {
            e.printStackTrace();
        }

When I test TLS and get Wireshark capture, I realized that Google Chrome as client has been sending certificate chain without root. As a result; intermediate certificate is not queried because of loop logic, because my code assumed the intermedite certificate is root.

How can I force client to send all nodes of the certificate chain?

Thanks


回答1:


I realized that Google Chrome as client has been sending certificate chain without root.

That is perfectly normal and the only correct behavior.

The root certificate is the trust anchor which has to be local to the party validating the certificate. Even if it is send it should be ignored when validating the certificate, i.e. only a local trust anchor should be used - otherwise a man in the middle could just provide his own certificate chain including his own root certificte. This means that in this case the server must have the root certificate already locally and thus there is no need for the client to send it.

In other words: don't try to change how Chrome behaves but instead adjust your expectations (and your code) on what the correct behavior is.




回答2:


I agree with Steffen but to give some more facts, here is what TLS 1.3 explicitly says:

certificate_list: A sequence (chain) of CertificateEntry structures, each containing a single certificate and set of extensions.

and

The sender's certificate MUST come in the first CertificateEntry in the list. Each following certificate SHOULD directly certify the one immediately preceding it. Because certificate validation requires that trust anchors be distributed independently, a certificate that specifies a trust anchor MAY be omitted from the chain, provided that supported peers are known to possess any omitted certificates.

and finally about ordering:

Note: Prior to TLS 1.3, "certificate_list" ordering required each certificate to certify the one immediately preceding it; however, some implementations allowed some flexibility. Servers sometimes send both a current and deprecated intermediate for transitional purposes, and others are simply configured incorrectly, but these cases can nonetheless be validated properly. For maximum compatibility, all implementations SHOULD be prepared to handle potentially extraneous certificates and arbitrary orderings from any TLS version, with the exception of the end-entity certificate which MUST be first.

So Chrome is correctly applying this specification. You need to change your end to cope with it.



来源:https://stackoverflow.com/questions/52203145/force-chrome-to-send-all-certificates-in-chain-during-tls

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