I am trying to get the directory list of a FTPS FileZilla server using the code below :
ftpRequest = (FtpWebRequest)FtpWebRequest.Create(host + "/" + directory);
ftpRequest.EnableSsl = true;
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateCertificate);
ftpRequest.Credentials = new NetworkCredential(user, pass);
ftpRequest.UseBinary = true;
ftpRequest.UsePassive = true;
ftpRequest.KeepAlive = true;
ftpRequest.Method = WebRequestMethods.Ftp.ListDirectory;
ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();
I got an exception when FtpWebResponse)ftpRequest.GetResponse()
is executed :
the underlying connection was closed. The server committed a protocol
violation.
When I switch to normal FTP connection. Everything works correctly.
Did I miss something to establish this FTPS connection ?
thanks for help
Best Answer
Implicit FTPS is not supported by the
FtpWebRequest
class (see here).When
EnableSsl
is set to true, it actually triggers anAUTH TLS
command to the server, asking to start an Explicit FTPS session.In your case, you have to configure Filezilla Server to use Explicit FTPS. The procedure is documented on Filezilla Wiki