Skip to content

FTP connection reuse not working in libcurl 8.12.1 #16384

@Zenju

Description

@Zenju

I did this

  1. Standard TLS-encypted connection to Apache FTP server.

  2. Multiple FTP accesses using ::curl_easy_reset() on the same curl easy handle

=> TLS-enabled FTP control connection is not reused, see Wireshark log:
Image

Analysis so far:

Problem is caused by:

  if((!(needle->handler->flags&PROTOPT_SSL) !=
      !Curl_conn_is_ssl(conn, FIRSTSOCKET)) &&
     !(get_protocol_family(conn->handler) == needle->handler->protocol &&
       conn->bits.tls_upgraded))
    /* Deny `conn` if it is not fit for `needle`'s SSL needs,
     * UNLESS `conn` is the same protocol family and was upgraded to SSL. */
      return FALSE;

https://github.com/icing/curl/blob/3be33a1a4777438e2ef9cca488322f789bdd40fd/lib/url.c#L955

In libcurl 8.11.1 this line was

  if ((needle->handler->flags&PROTOPT_SSL) !=
        (conn->handler->flags&PROTOPT_SSL))
        /* do not do mixed SSL and non-SSL connections */
        if (get_protocol_family(conn->handler) !=
            needle->handler->protocol || !conn->bits.tls_upgraded)
            /* except protocols that have been upgraded via TLS */
            return FALSE;

In the 8.12.1 code
Curl_conn_is_ssl(conn, FIRSTSOCKET) returns "true",

while in 8.11.1
(conn->handler->flags&PROTOPT_SSL) evaluated to "false".

Reverting this code section back to 8.11.1 fixed FTP connection reuse in my tests.

I expected the following

FTP control connection should be reused instead of needlessly creating a new one each time

curl/libcurl version

8.12.1

operating system

Windows 10

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions