0 votes
by (8.4k points)
edited

A following FtpWebRequest question was asked on MSDN forum

I tried using the FTPWebRequest object to do a secure FTP download through my proxy server. However, with the proxy object set correctly and EnableSSL=true, when I execute the getResponse method I get an exception of "SSL cannot be enabled when using a proxy." I will likely be using a production server that is behind the firewall and will thus need to communicate through the proxy server. Is there a .NEt way to do secure FTP through a proxy server?

In the forum post Microsoft confirmed that using FTP/SSL with proxy is not a supported scenario. Moreover System.Net.FtpWebRequest does support only FTP with explicit SSL security. SSL Implicit is not supported by System.Net.FtpWebRequest.

Could you share some code showing how to connect through proxy to FTP/SSL using Rebex FTP/SSL?

Applies to: Rebex FTP/SSL

1 Answer

0 votes
by (13.0k points)
edited

Following code shows how to download files from FTP server using a proxy server. Implicit TLS/SSL security is used.

// initialize FTP client 
Ftp client = new Ftp();

// setup proxy details 
client.Proxy.ProxyType = FtpProxyType.Socks5;
client.Proxy.Host = proxyHostname;
client.Proxy.Port = proxyPort;

// add proxy username and password when needed 
client.Proxy.UserName = proxyUsername;
client.Proxy.Password = proxyPassword;

// connect using TLS/SSL implicit. For unencrypted connection use
// client.Connect(hostname, port);
client.Connect(hostname, 990, null, FtpSecurity.Implicit);
client.Login(username, password);

// download file
client.GetFile("test.zip", @"c:\data\test.zip");

 // disconnect 
client.Disconnect();

Additional reading:

...