connection: shutdown TLS (for FTP) better

This adds connection shutdown infrastructure and first use for FTP. FTP
data connections, when not encountering an error, are now shut down in a
blocking way with a 2sec timeout.

    - add cfilter `Curl_cft_shutdown` callback
    - keep a shutdown start timestamp and timeout at connectdata
    - provide shutdown timeout default and member in
      `data->set.shutdowntimeout`.
    - provide methods for starting, interrogating and clearing
      shutdown timers
    - provide `Curl_conn_shutdown_blocking()` to shutdown the
      `sockindex` filter chain in a blocking way. Use that in FTP.
    - add `Curl_conn_cf_poll()` to wait for socket events during
      shutdown of a connection filter chain.
      This gets the monitoring sockets and events via the filters
      "adjust_pollset()" methods. This gives correct behaviour when
      shutting down a TLS connection through a HTTP/2 proxy.
    - Implement shutdown for all socket filters
      - for HTTP/2 and h2 proxying to send GOAWAY
      - for TLS backends to the best of their capabilities
      - for tcp socket filter to make a final, nonblocking
        receive to avoid unwanted RST states
    - add shutdown forwarding to happy eyeballers and
      https connect ballers when applicable.

Closes #13904
This commit is contained in:
Stefan Eissing 2024-06-07 10:12:39 +02:00 committed by Daniel Stenberg
parent 7d934267ab
commit c31041b17e
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
33 changed files with 1161 additions and 465 deletions

View file

@ -65,8 +65,6 @@ problems may have been fixed or changed somewhat since this was written.
7.2 Implicit FTPS upload timeout
7.3 FTP with NOBODY and FAILONERROR
7.4 FTP with ACCT
7.5 FTPS upload, FileZilla, GnuTLS and close_notify
7.11 FTPS upload data loss with TLS 1.3
7.12 FTPS directory listing hangs on Windows with Schannel
9. SFTP and SCP
@ -410,30 +408,6 @@ problems may have been fixed or changed somewhat since this was written.
thus fails to issue the correct command:
https://curl.se/bug/view.cgi?id=635
7.5 FTPS upload, FileZilla, GnuTLS and close_notify
An issue where curl does not send the TLS alert close_notify, which triggers
the wrath of GnuTLS in FileZilla server, and a FTP reply 426 ECONNABORTED.
https://github.com/curl/curl/issues/11383
7.11 FTPS upload data loss with TLS 1.3
During FTPS upload curl does not attempt to read TLS handshake messages sent
after the initial handshake. OpenSSL servers running TLS 1.3 may send such a
message. When curl closes the upload connection if unread data has been
received (such as a TLS handshake message) then the TCP protocol sends an
RST to the server, which may cause the server to discard or truncate the
upload if it has not read all sent data yet, and then return an error to curl
on the control channel connection.
Since 7.78.0 this is mostly fixed. curl will do a single read before closing
TLS connections (which causes the TLS library to read handshake messages),
however there is still possibility of an RST if more messages need to be read
or a message arrives after the read but before close (network race condition).
https://github.com/curl/curl/issues/6149
7.12 FTPS server compatibility on Windows with Schannel
FTPS is not widely used with the Schannel TLS backend and so there may be more