From: Olivier Houchard Date: Tue, 1 Dec 2026 14:35:29 +0000 (+0100) Subject: BUG/MEDIUM: ssl: ignore unexpected EOFs reported by the SSL library X-Git-Url: https://git.kaiwu.me/http/%22../doc/static/%7B@url%7D?a=commitdiff_plain;h=f5ba13f143bbb15767fc1ed9bb6de57b6b6c14fd;p=haproxy.git BUG/MEDIUM: ssl: ignore unexpected EOFs reported by the SSL library 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. --- diff --git a/src/ssl_sock.c b/src/ssl_sock.c index 42e880843..c29647458 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -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)