Repository navigation
Conversation
Anion3r
marked this pull request as ready for review
October 16, 2026 11:59
This branch has not been deployed
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
mbedtls_ssl_write()returnsWANT_READorWANT_WRITE, it must be retried with the same arguments until that write completes.WebSocketTransportcan append to or reallocate its send queue between retries, whileSocketMbedTLS::send()forwards the new pointer and length directly.This can acknowledge more bytes than were actually delivered: in the deterministic regression, an 8-byte pending tail is retried after another buffer is queued, and the receiver obtains only 49,176 of 65,552 bytes. The resulting gap can remove a WebSocket frame header and cause a protocol-error close.
The adapter now owns a pending copy of at most 16 KiB and preserves its address and length across retryable writes. It returns the actual completed count, clears pending state on completion/error/close, rejects retries shorter than the pending input, and prevents a fatal TLS error from retaining a stale would-block status. Public method signatures and TLS verification policy are unchanged.
Adds a Catch2 memory-BIO test target that uses real Mbed TLS sessions, without external networking, to cover:
The fixture derives its tail size from the active TLS record limit. A private friend accessor keeps session setup in test code. Windows test support links bcrypt for Mbed TLS builds using CNG entropy.
Validation
Tested against Mbed TLS 3.6.5, with a TLS 1.2 PSK memory fixture:
The default suite no longer depends on public hosts: DNS/connection checks use loopback addresses and a malformed IPv6 literal, WebSocket start/stop checks use a local echo server, and HTTP redirects use a second local server with an exact response-body assertion. The external Google HTTPS section was removed; existing local TLS-server tests retain real connection/CA verification coverage on Linux. The Windows suite currently has no equivalent local TLS-server target, so its memory-BIO regressions do not cover production TLS connection/CA loading. HTTP gzip assertions now follow
IXWEBSOCKET_USE_ZLIBinstead of failing when zlib is disabled.The complete Linux run also passed with a temporary guard that aborts external hostname lookups and non-loopback connections (the explicitly malformed
::invalidinput is allowed to exercise local resolver failure). Before the test cleanup, that same guard failed immediately on the existing Google DNS lookup. The guard is validation tooling outside the patch. The Windows complete run used local test endpoints without that guard. No default CTest targets were disabled.Build with
USE_TLS=ON,USE_MBED_TLS=ON,USE_TEST=ON,USE_WS=OFF,USE_ZLIB=OFF, and an installed Mbed TLS prefix. Then:Mbed TLS 2.x/4.x and other TLS backends were not executed in this environment. The memory fixture explicitly skips configurations without its TLS 1.2 PSK/PSA prerequisites.
Reference: Mbed TLS write retry contract.