Skip to content

Report TLS EOF and terminal errors consistently across backends - #650

Merged
bsergean merged 1 commit into
masterfrom
fix/tls-terminal-read-errors
Nov 17, 2026
Merged

bsergean merged 1 commit into
masterfrom
fix/tls-terminal-read-errors

Conversation

@bsergean

Copy link
Copy Markdown
Collaborator

Follow up #649 at the TLS adapter boundary. The shared reader handles a zero-byte EOF correctly, but TLS adapters can return -1 for terminal conditions while retaining a previous would-block status or reporting no native error.

  • OpenSSL: return zero for close_notify and set a non-wait error for fatal reads. Remove the redundant read loop.
  • Mbed TLS: distinguish close_notify, transport EOF, WANT_READ/WANT_WRITE, and fatal reads.
  • SecureTransport: return zero for a graceful receive shutdown and set a non-wait error for other terminal I/O failures, including the send fallback.

Network.framework already has explicit EOF/error mappings and needs no change. Readiness and cancellation behavior are preserved.

Tests exercise real TLS handshakes and reads through the existing in-memory OpenSSL/Mbed TLS fixtures, including close_notify, terminal failures after would-block, and completion of readBytes from TLS buffers. A SecureTransport context with deterministic failing I/O callbacks covers the legacy adapter. No new test uses a network connection, sleep or timeout wait.

Validation: the new terminal-read assertions fail on master. All memory adapter tests pass with OpenSSL 1.1.1w and 3.6 (196 assertions each), Mbed TLS 3 and 4 (232 each), and SecureTransport (10). ThreadSanitizer runs pass for OpenSSL 3.6, Mbed TLS 4 and SecureTransport. Existing Network.framework tests pass (72 assertions), as do the shared read regressions (25). Production builds as strict C++11 with warnings as errors; only the legacy SecureTransport build suppresses its existing deprecation diagnostics. Network.framework builds without that suppression. Formatting and diff checks passed.

@bsergean
bsergean merged commit 79fd1ed into master Nov 17, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant