From: Jean Baptiste Favre Date: Sat, 21 May 2022 17:28:31 +0000 (+0100) Subject: Bug fix in origin connection handling X-Git-Tag: archive/raspbian/8.1.1+ds-1.1+rpi1+deb11u1^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=1479f157ed3871ba49b73490bf587a9aafa02105;p=trafficserver.git Bug fix in origin connection handling Origin: upstream Applied-Upstream: https://github.com/apache/trafficserver/commit/d3f36f79820ea10c26573c742b1bbc370c351716 Reviewed-by: Jean Baptiste Favre Last-Update: 2022-05-21 Last-Update: 2022-05-21 Gbp-Pq: Name 0019-CVE_2021_44759.patch --- diff --git a/iocore/net/SSLNetVConnection.cc b/iocore/net/SSLNetVConnection.cc index 72b69133..216b7649 100644 --- a/iocore/net/SSLNetVConnection.cc +++ b/iocore/net/SSLNetVConnection.cc @@ -1041,8 +1041,7 @@ SSLNetVConnection::sslStartHandShake(int event, int &err) // Making the check here instead of later, so we only // do this setting immediately after we create the SSL object SNIConfig::scoped_config sniParam; - int8_t clientVerify = 0; - cchar *serverKey = this->options.sni_servername; + cchar *serverKey = this->options.sni_servername; if (!serverKey) { ats_ip_ntop(this->get_remote_addr(), buff, INET6_ADDRSTRLEN); serverKey = buff; @@ -1051,25 +1050,30 @@ SSLNetVConnection::sslStartHandShake(int event, int &err) SSL_CTX *clientCTX = nullptr; if (nps) { - clientCTX = nps->ctx; - clientVerify = nps->verifyLevel; + clientCTX = nps->ctx; } else { clientCTX = params->client_ctx; - // Keeping backwards compatability on the proxy.config.ssl.client.verify.server setting - clientVerify = params->clientVerify ? (params->clientVerify == 1 ? 2 : 1) : 0; } + if (!clientCTX) { SSLErrorVC(this, "failed to create SSL client session"); return EVENT_ERROR; } + if (nps && nps->verifyLevel != static_cast(YamlSNIConfig::Level::UNSET)) { + this->options.clientVerificationFlag = nps->verifyLevel; + } else { + // Keeping backwards compatibility on the proxy.config.ssl.client.verify.server setting + this->options.clientVerificationFlag = params->clientVerify ? (params->clientVerify == 1 ? 2 : 1) : 0; + } + this->ssl = make_ssl_connection(clientCTX, this); if (this->ssl == nullptr) { SSLErrorVC(this, "failed to create SSL client session"); return EVENT_ERROR; } int verify_op; - if (clientVerify) { + if (this->options.clientVerificationFlag) { verify_op = SSL_VERIFY_PEER; SSL_set_verify(this->ssl, verify_op, verify_callback); } else { diff --git a/iocore/net/YamlSNIConfig.h b/iocore/net/YamlSNIConfig.h index 7bdd6195..cfbeecf4 100644 --- a/iocore/net/YamlSNIConfig.h +++ b/iocore/net/YamlSNIConfig.h @@ -45,7 +45,7 @@ struct YamlSNIConfig { client_cert }; - enum class Level { NONE = 0, MODERATE, STRICT }; + enum class Level { NONE = 0, MODERATE, STRICT, UNSET }; enum class TLSProtocol : uint8_t { TLSv1 = 0, TLSv1_1, TLSv1_2, TLSv1_3, TLS_MAX = TLSv1_3 }; YamlSNIConfig() {} @@ -55,7 +55,7 @@ struct YamlSNIConfig { bool disable_h2 = false; uint8_t verify_client_level = 0; std::string tunnel_destination; - uint8_t verify_origin_server = 0; + uint8_t verify_origin_server = static_cast(Level::UNSET); std::string client_cert; std::string ip_allow; bool protocol_unset = true;