SSL_write partial data handling and WANT_WRITE limits
0 reputation · 25 Feb 2021, 16:03 UTC
When implementing non-blocking I/O with OpenSSL, SSL_write may return a value indicating that only a portion of the provided buffer was processed. This typically occurs when the underlying transport layer is saturated, triggering an SSL_ERROR_WANT_WRITE return code.
The primary design constraint is ensuring data integrity by avoiding duplicate writes. Because the SSL object manages an internal buffer, the application must precisely track the number of bytes successfully accepted by the library to determine the correct offset for the subsequent retry attempt.
There is uncertainty regarding the boundary of 'written' data when utilizing custom BIO implementations. Specifically, it is unclear how the library distinguishes between data that has been buffered internally versus data that has been physically transmitted to the transport layer during a partial write.
- How does OpenSSL determine the exact byte offset to return when a custom BIO triggers
SSL_ERROR_WANT_WRITE? - What is the guaranteed behavior for the internal buffer state when a write is interrupted mid-record?