aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/tls/tls_handshake_state.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2019-07-13 06:18:14 -0400
committerJack Lloyd <[email protected]>2019-07-13 06:18:14 -0400
commit3a3146b505400eda327dfe532ec583dee3ab092c (patch)
treeddbf172393b46d5681c02e628d5a14a978c440e6 /src/lib/tls/tls_handshake_state.cpp
parentf5e722a6b3be5b2b062c38bd269e4ebcece56d21 (diff)
parent8eb6e3321a6a239465359d5f98f153d84daf7eef (diff)
Merge GH #2030 Improve TLS invalid transition error messages
Diffstat (limited to 'src/lib/tls/tls_handshake_state.cpp')
-rw-r--r--src/lib/tls/tls_handshake_state.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/lib/tls/tls_handshake_state.cpp b/src/lib/tls/tls_handshake_state.cpp
index 8261cefbc..9c9390a22 100644
--- a/src/lib/tls/tls_handshake_state.cpp
+++ b/src/lib/tls/tls_handshake_state.cpp
@@ -144,6 +144,7 @@ std::string handshake_mask_to_string(uint32_t mask, char combiner)
HELLO_VERIFY_REQUEST,
HELLO_REQUEST,
CLIENT_HELLO,
+ SERVER_HELLO,
CERTIFICATE,
CERTIFICATE_URL,
CERTIFICATE_STATUS,
@@ -313,9 +314,21 @@ void Handshake_State::confirm_transition_to(Handshake_Type handshake_msg)
if(!ok)
{
- throw Unexpected_Message("Unexpected state transition in handshake, expected " +
- handshake_mask_to_string(m_hand_expecting_mask, '|') +
- " received " + handshake_mask_to_string(m_hand_received_mask, '+'));
+ const uint32_t seen_so_far = m_hand_received_mask & ~mask;
+
+ std::ostringstream msg;
+
+ msg << "Unexpected state transition in handshake got a " << handshake_type_to_string(handshake_msg);
+
+ if(m_hand_expecting_mask == 0)
+ msg << " not expecting messages";
+ else
+ msg << " expected " << handshake_mask_to_string(m_hand_expecting_mask, '|');
+
+ if(seen_so_far != 0)
+ msg << " seen " << handshake_mask_to_string(seen_so_far, '+');
+
+ throw Unexpected_Message(msg.str());
}
/* We don't know what to expect next, so force a call to