0 votes

I'm using ftp.dll to connect my sports app to the users designated server where this might be either via simple ftp or ftps. How can I detect whether to use client.Connect or client.ConnectSSL ?

Is there a server interrogation / response that will tell me this ?

Obviously the alternative is to make the user select which one before connecting, but is there an auto way using ftp.dll to detect which to use ?

by (750 points)

1 Answer

0 votes

Unfortunately the protocol doesn't provide such feature. In most cases you need to know upfront what settings to use.

Basically there are three modes in which Ftp.dll can work:

  • Plain - regular FTP connection, no security (port 21) - Connect method.

  • Implicit – where FTPS client immediately connects using secure channel (default port is 990) - ConnectSSL method.

  • Explicit – where FTP client connects on unsecured channel first (Connect on port 21) and then secures the communication by issuing AUTHTLS command (AuthTLS method).

After you connect on plain port, you may check if server supports explicit option and secure the connection:

client.Connect("ftp.example.com");

if (client.Extensions.SupportsAuthTLS)
{
     client.AuthTLS();
}

Generally I think your client should allow users to choose. For example:

  • Use plain FTP (insecure) - Use Connect
  • Use explicit FTP over SSL/TLS, if available - use Connect and AuthTLS, if SupportsAuthTLS
  • Require explicit FTP over SSL/TLS - use Connect and AuthTLS
  • Require implicit FTP over SSL/TLS - use ConnectSSL
by (297k points)
That's excellent, thanks.
...