+1 vote

I'm trying your DLL and have raised a purchase request for my organisation to purchase a license, but am having issues trying to download from a site we can access through Filezilla or winscp.

I'm using this code:

using (Ftp client = new Ftp())
{
    client.ConnectSSL(_hostname, 21);
    client.AuthTLS();
    client.Login(_user,_password);

    foreach (FtpItem item in client.GetList())
    {
        if (item.IsFolder == true)
            Console.WriteLine("[{0}]", item.Name);
        else
            Console.WriteLine("{0}", item.Name);
        }
        client.Close();
    }

The Filezilla settings are: port 21, FTP protocol & Use explicit FTP over TLS if available.

When I run the code, I get:
'Authenticate as SSL client failed. You might be connecting to non SSL port.'
'IOException: The handshake failed due to an unexpected packet format.'

I've tried changing the client.AuthTLS to AuthSSL as per your advice here: https://www.limilabs.com/blog/the-handshake-failed-due-to-an-unexpected-packet-format-ftp
but this doesn't work (and gives a deprecation warning to user AuthTLS instead).

Have you any ideas as to what's causing the issue?

by

1 Answer

0 votes
 
Best answer

Change the first line, so it connects without SSL/TLS :

client.ConnectSSL(_hostname, 21);
client.AuthTLS();

to:

client.Connect(_hostname);
client.AuthTLS();

Ftp.Connect uses port 21 by default and doesn't perform SSL/TLS negotiation after connection is established.

Next line (Ftp.AuthTLS) sends explicit SSL/TLS request, performs SSL/TLS negotiation on control channel and enforces PROT P on all subsequent FTP data transfers.

Full code follows:

using (Ftp client = new Ftp())
{
    client.Connect(_hostname);
    client.AuthTLS();
    client.Login(_user,_password);
by (297k points)
edited by
...