Skip to content

Commit f7067b2

Browse files
somecookiekinkie
authored andcommitted
Set SSL_OP_LEGACY_SERVER_CONNECT when peeking at servers (#2354)
Our TLS Server Hello parser does not treat legacy servers specially, but enabling legacy server support in OpenSSL allows OpenSSL to advance enough in its Server Hello processing to provide our SslBump code with the server certificate (that we then validate). Successful certificate validation, in turn, may result in Squid splicing the connection, even if OpenSSL detected other errors: noteNegotiationError: hold TLS write on FD 15 despite SQUID_TLS_ERR_CONNECT+TLS_LIB_ERR=2000068+TLS_IO_ERR=1 A spliced connection allows the TLS client to handle a legacy server the way the client needs to handle it, without unwanted Squid meddling. This is a Measurement Factory project.
1 parent 92178a5 commit f7067b2

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ Thank you!
440440
Reinhard Sojka <[email protected]>
441441
Rene Geile <[email protected]>
442442
Reuben Farrelly <[email protected]>
443+
Ricardo Ferreira Ribeiro <[email protected]>
443444
Richard Huveneers <[email protected]>
444445
Richard Huveneers <[email protected]>
445446
Richard Sharpe

src/ssl/PeekingPeerConnector.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "security/ErrorDetail.h"
1919
#include "security/NegotiationHistory.h"
2020
#include "SquidConfig.h"
21+
#include "src/base/IoManip.h"
2122
#include "ssl/bio.h"
2223
#include "ssl/PeekingPeerConnector.h"
2324
#include "ssl/ServerBump.h"
@@ -196,6 +197,22 @@ Ssl::PeekingPeerConnector::initialize(Security::SessionPointer &serverSession)
196197
srvBio->setClientFeatures(details, cltBio->rBufData());
197198
srvBio->recordInput(true);
198199
srvBio->mode(csd->sslBumpMode);
200+
201+
#if defined(SSL_OP_LEGACY_SERVER_CONNECT)
202+
// While peeking, Squid is not generating any TLS bytes, but we are
203+
// still being driven by OpenSSL negotiation logic. We enable as
204+
// many features and workarounds as possible to reduce cases where
205+
// OpenSSL refuses to accept a valid TLS server response. This code
206+
// assumes that an admin should not expect a peeking Squid to
207+
// automatically enforce a particular set of TLS conditions (e.g.,
208+
// "no legacy TLS servers"). When that assumption is invalidated, we
209+
// will need to add a configuration directive to set peeking TLS
210+
// options.
211+
if (csd->sslBumpMode == Ssl::bumpPeek && SSL_OP_LEGACY_SERVER_CONNECT) {
212+
const auto adjustedOptions = SSL_set_options(serverSession.get(), SSL_OP_LEGACY_SERVER_CONNECT);
213+
debugs(83, 5, "post-SSL_OP_LEGACY_SERVER_CONNECT options for session=" << serverSession << ": " << asHex(adjustedOptions));
214+
}
215+
#endif
199216
} else {
200217
const bool redirected = request->flags.redirected && ::Config.onoff.redir_rewrites_host;
201218
const char *sniServer = (!hostName || redirected) ?

0 commit comments

Comments
 (0)