A qustion about FtpWebRequest & SSL

Dear All,

I am developing an application which uploads/downloads files to a FTP server. My code was working properly until I enabled

SSLinFtpWebRequestobject

===========================

FtpWebRequest result = (FtpWebRequest)FtpWebRequest.Create(URI);

result.EnableSsl =true;

//Set the login details

result.Credentials = GetCredentials(); // sets user name and password and server url

//Do not keep alive (stateless mode)

result.KeepAlive =false;

=============================

Tehn this exception was thrown “The remote certificate is invalid according to the validation procedure”

After searching about this problem I found a hint in this foroum http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=620849&SiteID=1

You can change the implementation of ValidateServerCertificate() to "return true;" which happily swallows any certificate issue, but you should rather investigate what's wrong with the server certificate.

I did it

============================

ServicePointManager.ServerCertificateValidationCallback =newRemoteCertificateValidationCallback(MyCertValidationCb);

//create request

FtpWebRequest result = (FtpWebRequest)FtpWebRequest.Create(URI);

result.EnableSsl =true;

result.Credentials = GetCredentials();

//Do not keep alive (stateless mode)

result.KeepAlive =false;

return result;

}

publicstaticbool MyCertValidationCb(

object sender,

X509Certificate certificate,

X509Chain chain,

SslPolicyErrors sslPolicyErrors)

{

returntrue;

}

================================

but I got this exception:The remote server returned an error: 227 Entering Passive Mode (67,19,157,166,205,136)

Is there any other setting which I shall set in server or client Certificate?!

Any help will be appriciated.

Thanks in advance,

Saeideh

[8021 byte] By [Saeideh] at [2008-1-4]

.NET Development

Site Classified