Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add log format for whether origin TLS connection resumed an existing TLS session #8745

Merged
merged 1 commit into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/admin-guide/logging/formatting.en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,9 @@ cqssu Client Request SSL Elliptic Curve used by |TS| to communicate with the
cqssa Client Request ALPN Protocol ID negotiated with the client.
pqssl Proxy Request Indicates whether the connection from |TS| to the origin
was over SSL or not.
pqssr Proxy Request SSL session ticket reused status from |TS| to the origin;
indicates if the current request hit the SSL session ticket
and avoided a full SSL handshake.
pscert Proxy Request 1 if origin requested certificate from |TS| during TLS
handshake but no client certificate was defined. 2 if origin
requested certificate from |TS| during TLS handshake and a
Expand Down
14 changes: 13 additions & 1 deletion iocore/net/TLSSessionResumptionSupport.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ TLSSessionResumptionSupport::getSSLSessionCacheHit() const
return this->_sslSessionCacheHit;
}

bool
TLSSessionResumptionSupport::getSSLOriginSessionCacheHit() const
{
return this->_sslOriginSessionCacheHit;
}

ssl_curve_id
TLSSessionResumptionSupport::getSSLCurveNID() const
{
Expand Down Expand Up @@ -187,7 +193,7 @@ TLSSessionResumptionSupport::getOriginSession(SSL *ssl, const std::string &looku
shared_sess.reset();
} else {
SSL_INCREMENT_DYN_STAT(ssl_origin_session_cache_hit);
this->_setSSLSessionCacheHit(true);
this->_setSSLOriginSessionCacheHit(true);
this->_setSSLCurveNID(curve);
}
} else {
Expand Down Expand Up @@ -290,6 +296,12 @@ TLSSessionResumptionSupport::_setSSLSessionCacheHit(bool state)
this->_sslSessionCacheHit = state;
}

void
TLSSessionResumptionSupport::_setSSLOriginSessionCacheHit(bool state)
{
this->_sslOriginSessionCacheHit = state;
}

void
TLSSessionResumptionSupport::_setSSLCurveNID(ssl_curve_id curve_nid)
{
Expand Down
7 changes: 5 additions & 2 deletions iocore/net/TLSSessionResumptionSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class TLSSessionResumptionSupport
int enc);
#endif
bool getSSLSessionCacheHit() const;
bool getSSLOriginSessionCacheHit() const;
ssl_curve_id getSSLCurveNID() const;

SSL_SESSION *getSession(SSL *ssl, const unsigned char *id, int len, int *copy);
Expand All @@ -60,8 +61,9 @@ class TLSSessionResumptionSupport
private:
static int _ex_data_index;

bool _sslSessionCacheHit = false;
int _sslCurveNID = NID_undef;
bool _sslSessionCacheHit = false;
bool _sslOriginSessionCacheHit = false;
int _sslCurveNID = NID_undef;

#ifdef HAVE_SSL_CTX_SET_TLSEXT_TICKET_KEY_EVP_CB
int _setSessionInformation(ssl_ticket_key_block *keyblock, SSL *ssl, unsigned char *keyname, unsigned char *iv,
Expand All @@ -76,5 +78,6 @@ class TLSSessionResumptionSupport
#endif

void _setSSLSessionCacheHit(bool state);
void _setSSLOriginSessionCacheHit(bool state);
void _setSSLCurveNID(ssl_curve_id curve_nid);
};
4 changes: 4 additions & 0 deletions proxy/http/HttpSM.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6267,6 +6267,10 @@ HttpSM::attach_server_session()
server_connection_is_ssl = true;
}

if (auto tsrs = dynamic_cast<TLSSessionResumptionSupport *>(server_vc)) {
server_ssl_reused = tsrs->getSSLOriginSessionCacheHit();
}

server_protocol = server_txn->get_protocol_string();

// Initiate a read on the session so that the SM and not
Expand Down
1 change: 1 addition & 0 deletions proxy/http/HttpSM.h
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ class HttpSM : public Continuation, public PluginUserArgs<TS_USER_ARGS_TXN>
bool client_ssl_reused = false;
bool client_connection_is_ssl = false;
bool is_internal = false;
bool server_ssl_reused = false;
bool server_connection_is_ssl = false;
bool is_waiting_for_full_body = false;
bool is_using_post_buffer = false;
Expand Down
5 changes: 5 additions & 0 deletions proxy/logging/Log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,11 @@ Log::init_fields()
global_field_list.add(field, false);
field_symbol_hash.emplace("pqssl", field);

field = new LogField("proxy_req_ssl_reused", "pqssr", LogField::dINT, &LogAccess::marshal_proxy_req_ssl_reused,
&LogAccess::unmarshal_int_to_str);
global_field_list.add(field, false);
field_symbol_hash.emplace("pqssr", field);

field = new LogField("proxy_request_all_header_fields", "pqah", LogField::STRING, &LogAccess::marshal_proxy_req_all_header_fields,
&LogUtils::unmarshalMimeHdr);
global_field_list.add(field, false);
Expand Down
9 changes: 9 additions & 0 deletions proxy/logging/LogAccess.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2312,6 +2312,15 @@ LogAccess::marshal_proxy_req_is_ssl(char *buf)
return INK_MIN_ALIGN;
}

int
LogAccess::marshal_proxy_req_ssl_reused(char *buf)
{
if (buf) {
marshal_int(buf, m_http_sm->server_ssl_reused ? 1 : 0);
}
return INK_MIN_ALIGN;
}

/*-------------------------------------------------------------------------
-------------------------------------------------------------------------*/

Expand Down
1 change: 1 addition & 0 deletions proxy/logging/LogAccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ class LogAccess
int marshal_proxy_host_name(char *); // STR
int marshal_proxy_host_ip(char *); // STR
int marshal_proxy_req_is_ssl(char *); // INT
int marshal_proxy_req_ssl_reused(char *); // INT
int marshal_proxy_req_all_header_fields(char *); // STR

//
Expand Down