Preserve configured order of intermediate CA certificate chain#956
Preserve configured order of intermediate CA certificate chain#956rousskov wants to merge 1 commit intosquid-cache:masterfrom
Conversation
Those changes are nearly ready. I extracted this order fix and the #955 changes from a large/complex patch that improves certificate handling. That patch is finishing internal review/testing cycles. Factory will post the corresponding PR (or PRs) when these two surgical fixes are closed. |
https_port ... tls-cert=signing,itsIssuer,itsIssuerIssuer.pem The order was reversed in commit cf48712, probably by accident. Wrong order violates TLS protocol and breaks TLS clients that are incapable of reordering received intermediate CAs. Squid deployments that use wrong-order bundles (to compensate for this bug) should reorder their bundles when deploying this fix (or wait for Squid to order certificates correctly, regardless of the bundle order -- a work in progress). OpenSSL sends the signing certificate first. After that, OpenSSL sends certificates in the order they are stored in the chain, so we must push them in on-the-wire order, as defined by RFC 8446 Section 4.4.2: "The sender's certificate MUST come in the first CertificateEntry in the list. Each following certificate SHOULD directly certify the one immediately preceding it."
600c204 to
5ee4efa
Compare
yadij
left a comment
There was a problem hiding this comment.
Veto. The relevant RFC 8446 text is "Each following certificate SHOULD directly certify the one immediately preceding it."
Note the words preceding it. That means the chain is required to have the following syntax:
cert -> issuer CA 1 -> issuer CA 2 -> (optional) root CA
The value stored in latestCert is verified by X509_check_issued() to be certified by the previous entry appended to chain (ie its tail). Which makes emplace_back the correct RFC compliant logic if we assume the input file is correct.
Official code violates the above RFC requirement. Official code reverses the RFC-prescribed chain order to become: (optional) root CA -> issuer CA 2 -> issuer CA 1. Here is a simplified (but equivalent) version of the official code and the proposed change, preserving unfortunate official variable names: ca = loadNextCertificateFromTheBundle();
X509_check_issued(ca, latestCert); // i.e. ca signed/issued/certified latestCert
- chain.emplace_front(ca); // XXX: LIFO; Root (the last certificate to load) becomes the first chain entry
+ chain.emplace_back(ca); // OK: FIFO; Root is the last chain entry
latestCert = ca;
I cannot find a way to interpret what you are saying so that it matches official code. There is an interpretation that matches PR code, but that does not explain your veto. Here is what is actually going on in this very confusing code, in more precise/clear terms:
Exactly! Why are you vetoing the PR that does what you describe as "correct RFC compliant logic"? Here is what the PR diff says, verbatim: - chain.emplace_front(latestCert);
+ chain.emplace_back(latestCert);Footnotes
|
|
Sorry, misread the patch. :( cleared for merge now. |
https_port ... tls-cert=signing,itsIssuer,itsIssuerIssuer.pem The order was reversed in commit cf48712, probably by accident. Wrong order violates TLS protocol and breaks TLS clients that are incapable of reordering received intermediate CAs. Squid deployments that use wrong-order bundles (to compensate for this bug) should reorder their bundles when deploying this fix (or wait for Squid to order certificates correctly, regardless of the bundle order -- a work in progress). This is a Measurement Factory project.
…ain (squid-cache#956) https_port ... tls-cert=signing,itsIssuer,itsIssuerIssuer.pem The order was reversed in commit cf48712, probably by accident. Wrong order violates TLS protocol and breaks TLS clients that are incapable of reordering received intermediate CAs. Squid deployments that use wrong-order bundles (to compensate for this bug) should reorder their bundles when deploying this fix (or wait for Squid to order certificates correctly, regardless of the bundle order -- a work in progress). This is a Measurement Factory project.
…ain (#956) https_port ... tls-cert=signing,itsIssuer,itsIssuerIssuer.pem The order was reversed in commit cf48712, probably by accident. Wrong order violates TLS protocol and breaks TLS clients that are incapable of reordering received intermediate CAs. Squid deployments that use wrong-order bundles (to compensate for this bug) should reorder their bundles when deploying this fix (or wait for Squid to order certificates correctly, regardless of the bundle order -- a work in progress). This is a Measurement Factory project.
The order was reversed in commit cf48712, probably by accident. Wrong
order violates TLS protocol and breaks TLS clients that are incapable of
reordering received intermediate CAs. Squid deployments that use
wrong-order bundles (to compensate for this bug) should reorder their
bundles when deploying this fix (or wait for Squid to order certificates
correctly, regardless of the bundle order -- a work in progress).
This is a Measurement Factory project.