CONC-818 report CR_SERVER_LOST on TLS connection close#308
Draft
FaramosCZ wants to merge 1 commit intomariadb-corporation:3.4from
Draft
CONC-818 report CR_SERVER_LOST on TLS connection close#308FaramosCZ wants to merge 1 commit intomariadb-corporation:3.4from
FaramosCZ wants to merge 1 commit intomariadb-corporation:3.4from
Conversation
When the server closes a connection, ma_tls_read() in the OpenSSL and GnuTLS plugins unconditionally calls ma_tls_set_error(), which sets CR_SSL_CONNECTION_ERROR. The caller ma_net_safe_read() then preserves that error code instead of reporting the correct CR_SERVER_LOST. The Schannel plugin already handles this correctly: it returns 0 on SEC_I_CONTEXT_EXPIRED without setting any TLS error (schannel.c:640-642). Apply the same logic to OpenSSL and GnuTLS. Detect connection close and return 0 without setting error: OpenSSL: - SSL_ERROR_ZERO_RETURN: orderly close (close_notify) - SSL_ERROR_SYSCALL with empty error queue: EOF without close_notify (OpenSSL 1.x) - SSL_ERROR_SSL with SSL_R_UNEXPECTED_EOF_WHILE_READING: same EOF, reported differently by OpenSSL 3.x GnuTLS: - rc == 0: orderly close (close_notify) - GNUTLS_E_PREMATURE_TERMINATION: EOF without close_notify (GnuTLS 3.7.4+) Co-Authored-By: Claude AI <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the server closes a connection, ma_tls_read() in the OpenSSL and GnuTLS plugins unconditionally calls
ma_tls_set_error(), which sets CR_SSL_CONNECTION_ERROR. The caller ma_net_safe_read() then preserves that error code instead of reporting the correct CR_SERVER_LOST.
The Schannel plugin already handles this correctly: it returns 0 on SEC_I_CONTEXT_EXPIRED without setting any TLS error (schannel.c:640-642).
Apply the same logic to OpenSSL and GnuTLS. Detect connection close and return 0 without setting error:
OpenSSL:
GnuTLS:
Related to MariaDB/server#4929