Ftp-ssl crashes after "Waiting for TLS negotiation"

The following code for simple secure ftp does not work on my Windows 7 machine, but does work successfully on a Server 2012 machine on a different network. If I delete EnableSsl = true

it works fine.

public static string TheContent(string url, string username, string password)
{
    ServicePointManager.ServerCertificateValidationCallback = OnValidateCertificate;//returns true.

    string result = "";
    FtpWebRequest request = (FtpWebRequest)WebRequest.Create(url);
    request.Timeout = 7000;
    request.EnableSsl = true;
    request.UsePassive = true;
    request.Method = WebRequestMethods.Ftp.ListDirectory;
    request.Credentials = new NetworkCredential(username, password);
    using (FtpWebResponse response = (FtpWebResponse)request.GetResponse())
    using (StreamReader reader = new StreamReader(response.GetResponseStream()))
        result = reader.ReadToEnd();
    return result;
}

      

I've tried a lot of things. Some of them:

  • Disable firewall. (Although I am using passive mode)
  • Setting up port forwarding on my router.
  • Using "active".
  • Using FileZilla (doesn't work the same)
  • Connecting to a modem using a cable
  • More waiting time

And further.

I always get an exception at (FtpWebResponse)request.GetResponse()

"Unable to read data from the transport connection: the connection attempt failed because the related party responded incorrectly after a certain period of time, or the established connection failed because the connected host could not respond."

When using Microsoft Network Monitor 3.4, I see that the error looks like this:

FTP: reply to port, 234 AUTH command ok. Pending TLS Negotiation.

FTP: reply to port, '451 Parameter is invalid.

Any ideas? Could it be that non-server Windows are not capable of this by default, and something must be enabled first?

+3


source to share





All Articles