Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@pluknet
Copy link
Contributor

@pluknet pluknet commented Sep 10, 2025

This was broken in 7468a10 (1.29.0), resulting in a missing diagnostics and SSL error queue not cleared for SSL handshakes rejected by SNI, seen as "ignoring stale global SSL error" alerts, for instance, when doing SSL shutdown of a long standing connection after rejecting another one by SNI.

The fix is to move the qc->error check after c->ssl->handshake_rejected is handled first, to make the error queue cleared. Although not practicably visible as needed, this is accompanied by clearing the error queue under the qc->error case as well, to be on the safe side.

As an implementation note, due to the way of handling invalid transport parameters for OpenSSL 3.5 and above, which leaves a passed pointer not advanced on error, SSL_get_error() may return either SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE depending on a library. To cope with that, both qc->error and c->ssl->handshake_rejected checks were moved out of "sslerr != SSL_ERROR_WANT_READ".

Also, this reconstructs a missing "SSL_do_handshake() failed" diagnostics for the qc->error case, replacing using ngx_ssl_connection_error() with ngx_connection_error(). It is made this way to avoid logging at the crit log level because qc->error set is expected to have an empty error queue.

Reported and tested by Vladimir Homutov.

See for the initial report:
https://www.mail-archive.com/[email protected]/msg15286.html

@pluknet pluknet added this to the nginx-1.29.2 milestone Sep 10, 2025
@pluknet pluknet requested a review from arut September 10, 2025 14:13
@pluknet pluknet self-assigned this Sep 10, 2025
@pluknet pluknet added the bug label Sep 10, 2025
This was broken in 7468a10 (1.29.0), resulting in a missing diagnostics
and SSL error queue not cleared for SSL handshakes rejected by SNI, seen
as "ignoring stale global SSL error" alerts, for instance, when doing SSL
shutdown of a long standing connection after rejecting another one by SNI.

The fix is to move the qc->error check after c->ssl->handshake_rejected is
handled first, to make the error queue cleared.  Although not practicably
visible as needed, this is accompanied by clearing the error queue under
the qc->error case as well, to be on the safe side.

As an implementation note, due to the way of handling invalid transport
parameters for OpenSSL 3.5 and above, which leaves a passed pointer not
advanced on error, SSL_get_error() may return either SSL_ERROR_WANT_READ
or SSL_ERROR_WANT_WRITE depending on a library.  To cope with that, both
qc->error and c->ssl->handshake_rejected checks were moved out of
"sslerr != SSL_ERROR_WANT_READ".

Also, this reconstructs a missing "SSL_do_handshake() failed" diagnostics
for the qc->error case, replacing using ngx_ssl_connection_error() with
ngx_connection_error().  It is made this way to avoid logging at the crit
log level because qc->error set is expected to have an empty error queue.

Reported and tested by Vladimir Homutov.
@pluknet pluknet force-pushed the quic-stale-ssl-errors branch from a15aeb1 to 6bf241d Compare September 11, 2025 16:52
@pluknet
Copy link
Contributor Author

pluknet commented Sep 11, 2025

changes:
handshake may also fail in callbacks later, after ClientHello has been successfully processed, reported by @bavshin-f5

@pluknet pluknet requested a review from bavshin-f5 September 11, 2025 17:02
@pluknet pluknet merged commit eb5ebbb into nginx:master Sep 12, 2025
1 check passed
@pluknet pluknet deleted the quic-stale-ssl-errors branch September 12, 2025 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants