Skip to content

Conversation

scaprile
Copy link
Collaborator

@scaprile scaprile commented May 21, 2025

Handshake functions in Mongoose TLS assumed data was being fully sent after calling mg_io_send(). This was in fact the case with the usual 1460-bytes MSS, but not with the default 536-bytes MSS.
This PR removes all those calls from individual handshake functions, actual send is done at the main handshake function, keeping track of the amount of data sent, and so handling small MTUs/MSSs and possible MG_IO_WAITs when running over a socket layer.

There's still a corner case that will be addressed on an upcoming PR: When a client is establishing TLS, if the call to send FINISH fails to send all data, outstanding handshake data will remain in c->tls->send. Assuming the client application will send something when the connection has been established, this data will be sent along with the customer data. This is maybe the most common scenario. Otherwise, data will stay in that buffer and the connection will stall.
Something similar to the above can also happen when the last piece of encrypted data can't be sent (either whole or in part), c->send.len = 0 and c->tls->send won't be flushed, situation that replicates with MbedTLS and OpenSSL, and so will be addressed on the aforementioned upcoming PR.

@scaprile scaprile requested review from cpq and robertc2000 and removed request for cpq and robertc2000 May 21, 2025 19:52
@scaprile scaprile marked this pull request as draft May 21, 2025 19:58
Handshake functions in Mongoose TLS assumed data was being fully sent
after calling mg_io_send(). This was in fact the case with the usual 1460-bytes MSS, but not with the default 536-bytes MSS.
This PR removes all those calls from individual handshake functions, actual send is done at the main handshake function, keeping track of the amount of data sent, and so handling small MTUs/MSSs and possible MG_IO_WAITs when running over a socket layer.
@scaprile scaprile self-assigned this May 22, 2025
@scaprile scaprile marked this pull request as ready for review May 22, 2025 17:53
@scaprile scaprile requested review from cpq and robertc2000 May 22, 2025 17:53
@scaprile scaprile merged commit 5726e68 into master May 23, 2025
66 of 75 checks passed
@scaprile scaprile deleted the fairplay branch May 23, 2025 13:25
@scaprile scaprile mentioned this pull request May 23, 2025
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.

3 participants