]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MEDIUM: ssl: ignore unexpected EOFs reported by the SSL library
authorOlivier Houchard <ohouchard@haproxy.com>
Tue, 1 Dec 2026 14:35:29 +0000 (15:35 +0100)
committerOlivier Houchard <cognet@ci0.org>
Tue, 1 Dec 2026 14:25:21 +0000 (15:25 +0100)
When the peer closes the connection without sending a close_notify,
ha_ssl_read() returns 0. OpenSSL 4.0 and AWS-LC 5.9 now take this for an
unexpected EOF and fail the connection, where older versions reported a
syscall failure that ssl_sock_to_buf() handles as a regular shutdown.
Such closes are then logged as errors ("CD" or "SD") and the other side
gets a reset. With OpenSSL 4.0 a fatal alert is also emitted on the
closed connection, which prevents TLSv1.2 sessions from being resumed
and makes tcp-check-ssl.vtc fail.

Let's set SSL_OP_IGNORE_UNEXPECTED_EOF on the bind and server contexts
when the library provides it, so that such a close is reported as a
clean shutdown again.

This must be backported to all supported versions. This was reported in
GitHub issue #3605 by Yeonggi Kim, who also suggested this fix.

src/ssl_sock.c

index 42e880843ece88d5343255354f76970551f82b6c..c296474589be8ee82bdde032b3492982c1b9ca41 100644 (file)
@@ -4363,6 +4363,9 @@ ssl_sock_initial_ctx(struct bind_conf *bind_conf)
 #ifdef SSL_OP_NO_RENEGOTIATION
        options |= SSL_OP_NO_RENEGOTIATION;
 #endif
+#ifdef SSL_OP_IGNORE_UNEXPECTED_EOF
+       options |= SSL_OP_IGNORE_UNEXPECTED_EOF;
+#endif
 
 #ifdef SSL_OP_NO_RX_CERTIFICATE_COMPRESSION
        if (global_ssl.certificate_compression == 0)
@@ -5655,6 +5658,9 @@ static int ssl_sock_prepare_srv_ssl_ctx(const struct server *srv, SSL_CTX *ctx)
        else if (srv->ssl_ctx.renegotiate == SSL_RENEGOTIATE_ON)
                options &= ~SSL_OP_NO_RENEGOTIATION;
 #endif
+#ifdef SSL_OP_IGNORE_UNEXPECTED_EOF
+       options |= SSL_OP_IGNORE_UNEXPECTED_EOF;
+#endif
 
 #ifdef SSL_OP_NO_RX_CERTIFICATE_COMPRESSION
        if (global_ssl.certificate_compression == 0)