FtpWebRequest Self Signed Certificate (Auth TLS)
Posted by Anders Vindberg
in Lunarmedia Blog
on the 12 Apr. 2007 (46,063 views).
I recently installed Web Deployment Project (uses MSBuild which automatically comes with .Net 2.0) for Visual Studio 2005 to automate the website deployment process. A useful extension pack for MSBuild is called Community Tasks - in particular it includes Zip and FtpUpload tasks. Now we are getting to the point. If you need to make a SSL ftp connection (and approve a self-signed server certificate) using the FtpUpload task, you need to extend the current version of FtpUpload with the following (request is a FtpWebRequest instance, and EnableSSL is a public property):
request.EnableSsl = EnableSSL;
// This approves any Server Certificate (self-signed)
ServicePointManager.ServerCertificateValidationCallback = delegate(Object obj, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
return true;
};
If you dont want to mess with the community.tasks.dll library you can download the new dll and accompanied schema files from here:MSBuild.Community.Tasks with SSL FtpUpload support
Thanks to the following: Using FtpWebRequest to do FTP over SSL
On a specific note, if using FTP Serv-U you need to set its security level to "Allow SSL/TLS and regular sessions" to enable Auth TLS.