From: Olivier Houchard Date: Tue, 1 Dec 2026 14:35:29 +0000 (+0100) Subject: MEDIUM: ssl: never return 0 from the BIO read callback X-Git-Url: https://git.kaiwu.me/http/%22../doc/static/%7B@url%7D?a=commitdiff_plain;h=6e55119c13f6cfd4d73f8a0e3ade8aa8b7ccdafb;p=haproxy.git MEDIUM: ssl: never return 0 from the BIO read callback Commit "BUG/MEDIUM: ssl: ignore unexpected EOFs reported by the SSL library" sets SSL_OP_IGNORE_UNEXPECTED_EOF so that a close without a close_notify is no longer turned into an error by OpenSSL 4.0 and AWS-LC 5.9. But with this option, the library reports such a close exactly as if a close_notify had been received, so there is no way to tell them apart anymore. We don't use that information for now, but we may want to in the future. Let's remove the option, and make ha_ssl_read() return -1 with no retry flag instead of 0 when the connection is shut or in error, as is already done for a shutdown during a frontend handshake. The library then reports a syscall failure, as older versions did, which ssl_sock_to_buf() handles as a regular shutdown. This should not be backported, the commit above is enough for the stable versions. --- diff --git a/src/ssl_sock.c b/src/ssl_sock.c index c29647458..5e975724a 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -448,8 +448,10 @@ static int ha_ssl_read(BIO *h, char *buf, int size) ret = -1; } BIO_clear_retry_flags(h); - if (ret == 0 && !(ctx->conn->flags & (CO_FL_ERROR | CO_FL_SOCK_RD_SH))) { - BIO_set_retry_read(h); + if (ret == 0) { + /* never return 0, recent libs take it for an EOF and fail the connection */ + if (!(ctx->conn->flags & (CO_FL_ERROR | CO_FL_SOCK_RD_SH))) + BIO_set_retry_read(h); ret = -1; } #ifdef HA_USE_KTLS @@ -4363,9 +4365,6 @@ 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) @@ -5658,9 +5657,6 @@ 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)