This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new 72ca6d5b74 Don't count NIO TLS handshake processing time towards the
timeout
72ca6d5b74 is described below
commit 72ca6d5b748cf9822eafeea6c1573a91f235dc3b
Author: Mark Thomas <[email protected]>
AuthorDate: Sun Nov 8 12:04:13 2026 +0000
Don't count NIO TLS handshake processing time towards the timeout
The TLS handshake reads and writes the channel directly, so it does not
update the last read/write times. When a handshake step was slow (e.g. an
OCSP check of the client certificate) the Poller could time out the
connection as soon as read/write interest was registered.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
java/org/apache/tomcat/util/net/NioEndpoint.java | 9 +++++++++
webapps/docs/changelog.xml | 7 +++++++
2 files changed, 16 insertions(+)
diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java
b/java/org/apache/tomcat/util/net/NioEndpoint.java
index 9fc0ad0092..2152d7e86d 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -2262,8 +2262,17 @@ public class NioEndpoint extends
AbstractJsseEndpoint<NioChannel,SocketChannel>
getHandler().process(socketWrapper,
SocketEvent.CONNECT_FAIL);
poller.cancelledKey(getSelectionKey(), socketWrapper);
} else if (handshake == SelectionKey.OP_READ) {
+ /*
+ * The handshake reads from the channel directly so does
not update the last read time. Time spent
+ * processing the handshake (e.g. OCSP checks of the
client certificate) must not count towards
+ * the time spent waiting for the client else the Poller
may time out the connection as soon as
+ * read interest is registered.
+ */
+ ((NioSocketWrapper) socketWrapper).updateLastRead();
socketWrapper.registerReadInterest();
} else if (handshake == SelectionKey.OP_WRITE) {
+ // Same as for read above
+ ((NioSocketWrapper) socketWrapper).updateLastWrite();
socketWrapper.registerWriteInterest();
}
} catch (CancelledKeyException cx) {
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index b0e5674649..75ed3bdc90 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -578,6 +578,13 @@
connection, so the client saw a connection reset rather than the end of
the stream and could lose response data it had not yet read. (markt)
</fix>
+ <fix>
+ Ensure that time spent processing the TLS handshake with NIO, such as
+ OCSP checks of client certificates, is not counted towards the
+ connection timeout. Previously, a slow handshake could cause the
+ connection to be closed as soon as the server started waiting for the
+ client. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Jasper">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]