Skip to content

Commit f6eaeeb

Browse files
committed
HTTPCORE-782: non-blocking TLS session can end up in an endless loop in case of a protocol negotiation
1 parent d2ac9c9 commit f6eaeeb

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLIOSession.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -620,10 +620,11 @@ private void decryptData(final IOSession protocolSession) throws IOException {
620620
inPlainBuf.clear();
621621
}
622622
}
623-
if (result.getStatus() != SSLEngineResult.Status.OK) {
624-
if (result.getStatus() == SSLEngineResult.Status.BUFFER_UNDERFLOW && endOfStream) {
625-
throw new SSLException("Unable to decrypt incoming data due to unexpected end of stream");
626-
}
623+
if (result.getStatus() == SSLEngineResult.Status.BUFFER_UNDERFLOW && endOfStream) {
624+
throw new SSLException("Unable to decrypt incoming data due to unexpected end of stream");
625+
}
626+
if (result.getStatus() != SSLEngineResult.Status.OK ||
627+
result.getHandshakeStatus() != HandshakeStatus.NOT_HANDSHAKING && result.getHandshakeStatus() != HandshakeStatus.FINISHED) {
627628
break;
628629
}
629630
} finally {

0 commit comments

Comments
 (0)