Skip to content

Commit

Permalink
[mod_mbedtls] remove use of out_left in mbedtls 3
Browse files Browse the repository at this point in the history
remove use of ssl->out_left in mbedtls 3.0.0

Discussed in Mbed-TLS/mbedtls#5331,
the current implementations of mbedtls_net_send() and mbedtls_net_recv()
return MBEDTLS_ERR_SSL_WANT_WRITE only when there is a partial write
(though there is theoretical issue if writes are mixed with TLS alerts)

x-ref:
  "issues migrating lighttpd mod_mbedtls to mbedtls 3.0.0"
  Mbed-TLS/mbedtls#5331
  • Loading branch information
gstrauss committed Jan 19, 2022
1 parent 955c95b commit 4f48825
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/mod_mbedtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -2005,7 +2005,9 @@ mod_mbedtls_ssl_write_err(connection *con, handler_ctx *hctx, int wr, size_t wr_
return -1;
}

#if MBEDTLS_VERSION_NUMBER < 0x03000000 /* mbedtls 3.00.0 */
if (0 != hctx->ssl.out_left) /* partial write; save attempted wr_len */
#endif
hctx->pending_write = wr_len;

return 0; /* try again later */
Expand All @@ -2024,7 +2026,10 @@ connection_write_cq_ssl (connection * const con, chunkqueue * const cq, off_t ma

if (hctx->pending_write) {
int wr = (int)hctx->pending_write;
if (0 != ssl->out_left) {
#if MBEDTLS_VERSION_NUMBER < 0x03000000 /* mbedtls 3.00.0 */
if (0 != ssl->out_left)
#endif
{
/*(would prefer mbedtls_ssl_flush_output() from ssl_internal.h)*/
size_t data_len = hctx->pending_write;
wr = mbedtls_ssl_write(ssl, NULL, data_len);
Expand Down

0 comments on commit 4f48825

Please sign in to comment.