Client.Connect()

Aug 4, 2009 at 10:09 PM

Hi,

I was able to connect to a SFTP site with command line.  Now I'm trying to use class library. I've used different parameters for FTPSClient.Connect but keep getting error. What's parameters should I use?

Command line: ftps -h mySiteUri -ssl Implicit -U myUser -l /inbox/

Error when using class library:  {"A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond xxx.xxx.xx.xx:21"}

Appreciate for any suggestions.

Thanks,

Victor

Aug 4, 2009 at 10:25 PM

Hi,

After using Implicit, I seems connect to the FTP site but I got the error at Client.Connect().

"The remote certificate is invalid according to the validation procedure."

I got the same message in command line, but I was able to type Y.

I used the sample code provided in home page.

Thanks,

Victor

Coordinator
Aug 4, 2009 at 10:55 PM
Edited Aug 4, 2009 at 10:55 PM

Hi,

to unconditionally accept invalid server certificates just implement a RemoteCertificateValidationCallback delegate and pass it to the Connect method as in the following code snippet:

private static bool ValidateTestServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
     // Accept any certificate
     return true;
}

client.Connect(..., new RemoteCertificateValidationCallback(ValidateTestServerCertificate), ...);

You might also add some more complex logic, based on your needs. The certificate, chain and sslPolicyErrors parameters provide the necessary context.

Cheers,

Alessandro

Aug 5, 2009 at 8:13 PM

Hi Alex,

Thanks for the suggestion and it works.

Victor

May 25, 2012 at 7:01 PM

No matter what I try, still get a handshake error.  Any idea, anyone?  I also setup my code so it accepts ANY certificate.  I even downloaded the source code and tried to run it from Visual Studio.  The command project that the source has attached also gives me the same handshake error.