I'm developing a small application to upload a file via ftps implicit ssl but I've reached the point where it's trying to connect and I catch the error saying 'The underlying connection was closed: The server committed a protocol violation'.
I have looked for a solution to this but can't find anything. I have copied the code below.
The code reaches FtpWebResponse response = (FtpWebResponse)request.GetResponse()
and hangs until it falls into the catch.
Also to note the string status field returns null during the exception.
string ftps = "ftp://100.0.0.1:990/Test"
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftps);
request.KeepAlive = true;
request.EnableSsl = true;
request.UsePassive = true;
request.UseBinary = true;
request.Credentials = new NetworkCredential("user", "Password");
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateCertificate);
try
{
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
request.Method = WebRequestMethods.Ftp.UploadFile;
}
catch (WebException e)
{
String status = ((FtpWebResponse)e.Response).StatusDescription;
}
private bool ValidateCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true;
}