The handshake failed due to an unexpected packet format.

May 9, 2012 at 9:20 PM

I'm trying to connect to a FTPS protocol and here are some of the code .. but running into this "handshake" problem.  Can someone please help?  Thanks.

using (FtpClient ftp = new FtpClient() { Server = "my.host.com", 
                Username = "username", 
                Password = "password", 
                DataChannelType = FtpDataChannelType.Active, 
                SslMode = FtpSslMode.Implicit, 
                Port = 21 })
            {
                ftp.InvalidCertificate += new FtpInvalidCertificate(ftp_InvalidCertificate);

                try
                {
                    FtpListItem[] items = ftp.GetListing("/some/folder/for/listing/");

                    foreach (FtpListItem item in items)
                    {
                        Console.WriteLine("{0} {1}", item.Name, item.Type.ToString());
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

Coordinator
May 9, 2012 at 9:24 PM

Is the server you're connecting to setup to accept only SSL connections on port 21? If not you need to be using Explicit.