FISH-631 Prevent infinite loop when using TLS 1.3 #27
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Under certain conditions when using TLS 1.3 and JDK11, an infinite loop can occur during handshaking (until it times out anyway).
This appears to be in some way related to the behaviour of TLS 1.3 not requiring a closeNotify to be sent (the issue disappears when the system property to bring back the old behaviour is active).
Following the logic of the unwrapAll method and the output of the log, it appears to occur when trying to gracefully terminate the SSL connection - I'm not really sure why it's trying to handshake to close a connection but that's a separate issue and likely just a gap in my knowledge.
The flow of things goes as follows:
SSLBaseFilter.handleRead
->SSLBaseFilter.unwrapAll
(I believe line 293, since the next log messages are to withunwrap
rather thandoHandshakeStep
)unwrapAll
loopStatus = OK HandshakeStatus = NOT_HANDSHAKING
Status = CLOSED HandshakeStatus = NEED_WRAP
silentRehandshake
method.doHandshakeSync
, specifically line 576/577, before it enters the do while loop at line 579.Status = OK HandshakeStatus = NEED_WRAP
doHandshakeSync
(line 576/577)Presumably the other side has closed the connection but hasn't sent a closeNotify, causing this side (Payara in this case) to continually attempt to handshake with it on a no longer active connection. Again, I'm not clear on how the current graceful SSL connection termination is meant to work and why handshaking is a part of this, but this added change appears to work (even if it is a bit brutal in essentially killing the connection dead) - more graceful solutions are likely available.
Example log for reference (line numbers may be slightly off in a couple of places due to Payara having a few unsynced changes):
Signed-off-by: Andrew Pielage [email protected]