]> git.ipfire.org Git - thirdparty/squid.git/commit
Handling missing issuer certificates for TLSv1.3 (#766)
authorChristos Tsantilas <christos@chtsanti.net>
Mon, 22 Feb 2021 21:15:32 +0000 (21:15 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Tue, 23 Feb 2021 19:28:57 +0000 (19:28 +0000)
commit800967afde7921eb22a2711c5a75b5cd9c9d7178
tree7cc8dfb8d3f1b015f12dfdd6a32395c40296483d
parent9205b24a4029f2ca569f5e92c8247d2ac1ecc0c6
Handling missing issuer certificates for TLSv1.3 (#766)

Prior to TLS v1.3 Squid could detect and fetch missing intermediate
server certificates by parsing TLS ServerHello. TLS v1.3 encrypts the
relevant part of the handshake, making such "prefetch" impossible.

Instead of looking for certificates in TLS ServerHello, Squid now waits
for the OpenSSL built-in certificate validation to fail with an
X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY error. Squid-supplied
verify_callback function tells OpenSSL to ignore that error. Squid
SSL_connect()-calling code detects that the error was ignored and, if
possible, fetches the missing certificates and orchestrates certificate
chain validation outside the SSL_connect() sequence. If that validation
is successful, Squid continues with SSL_connect(). See comments inside
Security::PeerConnector::negotiate() for low-level details.

In some cases, OpenSSL is able to complete SSL_connect() with an ignored
X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY error. If Squid validation
fails afterwards, the TLS connection is closed (before any payload is
exchanged). Ideally, the negotiation with an untrusted server should not
complete, but complexity BIO changes required to prevent such premature
completion is probably not worth reaching that ideal, especially since
all of this is just a workaround.

The long-term solution is adding SSL_ERROR_WANT_RETRY_VERIFY to OpenSSL,
giving an application a chance to download the missing certificates
during SSL_connect() negotiations. We assist OpenSSL team with that
change, but it will not be available at least until OpenSSL v3.0.

This description and changes are not specific to SslBump code paths.

This is a Measurement Factory project.
15 files changed:
acinclude/lib-checks.m4
compat/openssl.h
src/security/Handshake.cc
src/security/Handshake.h
src/security/Io.cc
src/security/Io.h
src/security/PeerConnector.cc
src/security/PeerConnector.h
src/security/Session.h
src/ssl/bio.cc
src/ssl/bio.h
src/ssl/gadgets.h
src/ssl/support.cc
src/ssl/support.h
src/tests/stub_libsecurity.cc