Skip to content

Commit faf730a

Browse files
shinrichzwoop
authored andcommitted
Check sni against SSL object (#6656)
Co-authored-by: Susan Hinrichs <shinrich@verizonmedia.com> (cherry picked from commit 1f6a6fd)
1 parent 50d8f22 commit faf730a

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

iocore/net/I_NetVConnection.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,12 @@ class NetVConnection : public VConnection, public PluginUserArgs<TS_USER_ARGS_VC
649649
return false;
650650
}
651651

652+
virtual const char *
653+
get_sni_servername() const
654+
{
655+
return nullptr;
656+
}
657+
652658
/** Structure holding user options. */
653659
NetVCOptions options;
654660

iocore/net/P_SSLNetVConnection.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,12 @@ class SSLNetVConnection : public UnixNetVConnection, public ALPNSupport
454454
verify_cert = ctx;
455455
}
456456

457+
const char *
458+
get_sni_servername() const override
459+
{
460+
return SSL_get_servername(this->ssl, TLSEXT_NAMETYPE_host_name);
461+
}
462+
457463
private:
458464
std::string_view map_tls_protocol_to_tag(const char *proto_string) const;
459465
bool update_rbio(bool move_to_socket);

proxy/http/HttpSessionManager.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ ServerSessionPool::validate_host_sni(HttpSM *sm, NetVConnection *netvc)
8585
// by fetching the hostname from the server request. So the connection should only
8686
// be reused if the hostname in the new request is the same as the host name in the
8787
// original request
88-
const char *session_sni = netvc->options.sni_servername;
88+
const char *session_sni = netvc->get_sni_servername();
8989
if (session_sni) {
9090
// TS-4468: If the connection matches, make sure the SNI server
9191
// name (if present) matches the request hostname
@@ -106,7 +106,7 @@ ServerSessionPool::validate_sni(HttpSM *sm, NetVConnection *netvc)
106106
// a new connection.
107107
//
108108
if (sm->t_state.scheme == URL_WKSIDX_HTTPS) {
109-
const char *session_sni = netvc->options.sni_servername;
109+
const char *session_sni = netvc->get_sni_servername();
110110
std::string_view proposed_sni = sm->get_outbound_sni();
111111
Debug("http_ss", "validate_sni proposed_sni=%s, sni=%s", proposed_sni.data(), session_sni);
112112
if (!session_sni || proposed_sni.length() == 0) {

0 commit comments

Comments
 (0)