Repository navigation
Conversation
|
Analysis of PR #23368 at 390aad2d: Test ../../tests/http/test_20_websockets.py::TestWebsockets::test_20_11_crazy_pings failed, but it has been 0.3% flaky lately, so it's probably NOT a fault of the PR. Note that this test has failed in 2 different CI jobs (the link just goes to one of them). Generated by Testclutch |
|
updated description with motivation for the fix |
|
I've modified this slightly to address two things. First the shutdown offset should not be advanced if the send call has failed (result != 0) so now we if(!result). Second it was unclear what happened when remaining shutdown message bytes to send was 0 and sent_shutdown == FALSE, like how could this happen unless the message generated by schannel was empty, so I addressed this specifically by doing it like if(remaining) result = send bytes; else result = CURLE_OK; |
|
Thanks, Jay. The follow-up looks reasonable and preserves the original shutdown-retry fix. Advancing the offset only on CURLE_OK is sensible defensive accounting. Blocked or failed sends leave the pending ciphertext at the same offset, while successful partial writes still advance correctly. Two minor observations: The previous written > remaining check was removed. I haven’t identified a concrete regression from that under normal send behavior, but retaining the check on successful sends would preserve defensive validation. |
That's ok. send will never return a written count greater than the length passed to send.
That's also ok. We don't need to test every single improbable outlier. |
32f6113 to
5dd041d
Compare
Keep the SSPI shutdown token and its sent offset until the complete record has been written. Regenerating it after CURLE_AGAIN loses an encrypted record and can make the peer reject the next record. Handle short writes without advancing the TLS context again and free pending tokens when the connection closes. Add a native unit test for would-block, partial writes, pending-token cleanup and send failures. Prior to this change libcurl didn't properly handle the case where the close_notify TLS record could not be sent in full on the first try. Microsoft observed FTPS upload failures due to this problem. Refer to the pull request for more detail. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Closes curl#23368
Keep the SSPI shutdown token and its sent offset until the complete record has been written. Regenerating it after CURLE_AGAIN loses an encrypted record and can make the peer reject the next record. Handle short writes without advancing the TLS context again and free pending tokens when the connection closes. Add a native unit test for would-block, partial writes, pending-token cleanup and send failures. Prior to this change libcurl didn't properly handle the case where the close_notify TLS record could not be sent in full on the first try. Microsoft observed FTPS upload failures due to this problem. Refer to the pull request for more detail. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Closes curl#23368
5dd041d to
978bfe9
Compare
|
Thanks |
Motivation
While testing FTPS interoperability with Windows curl 8.21.0 using Schannel, we observed intermittent upload failures during TLS shutdown of the data connection. The server could receive the 64 KiB test payload but still return FTP 451, with SSPI error 0x80090330, instead of completing the transfer successfully. This occurred with both TLS 1.2 and TLS 1.3.
Receiving the payload was not sufficient: the encrypted data connection still needed to close correctly before the upload could be considered successful.
We isolated the failure using an independent, memory-only FTPS fixture. This demonstrated a curl client-side retry defect rather than a dependency on the original server’s authentication or storage implementation.
Root cause and correction
When the transport returns CURLE_AGAIN while sending Schannel’s encrypted close_notify, curl frees the unsent SSPI output token. The next shutdown call generates a new encrypted record instead of retrying the original ciphertext. This advances the TLS record sequence and can cause the peer to reject the next record.
This PR:
Retains the generated shutdown token and its sent offset until the complete record has been written.
Retries the same remaining ciphertext after would-block or short writes.
Releases pending tokens during connection cleanup.
The goal is reliable FTPS transfer completion without server-side workarounds or relaxed TLS checks. Certificate verification and TLS session reuse are unchanged.
Validation
AI assistance was used for the investigation and patch. The failure and correction were verified with executable before/after tests.