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.
#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)
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)