I am being asked to support implicit and explicit FTPS (also known as FTPES). We are currently using the .NET FtpWebRequest. Does the FtpWebRequest support both types of FTPES, and what is the difference?
Thanks
I am being asked to support implicit and explicit FTPS (also known as FTPES). We are currently using the .NET FtpWebRequest. Does the FtpWebRequest support both types of FTPES, and what is the difference?
Thanks
edtFTPnet/PRO is an FTP client library that also supports FTPS implicit and explicit modes. It's simply a matter of specifying the right protocol:
SecureFTPConnection conn = new SecureFTPConnection();
conn.Protocol = FileTransferProtocol.FTPSImplicit;
// set remote host, user, pwd etc ...
// now connect
conn.Connect();
The same component supports SFTP also.
And yes, I am one of the developers of this component (and of edtFTPnet, the free, open source .NET FTP client).
Using FTP over implicit SSL is not quite as straightforward, but it can be done in .NET without the use of any 3rd party library. Since implicit SSL is basically FTP commands done over an SSL connection we just need to setup an SSL connection with .NET, then issue the commands we need to download the file.
// Open a connection to the server over port 990
// (default port for FTP over implicit SSL)
using (TcpClient client = new TcpClient("localhost", 990))
using (SslStream sslStream = new SslStream(client.GetStream(), true))
{
// Start SSL/TLS Handshake
sslStream.AuthenticateAsClient("localhost");
// Setup a delegate for writing FTP commands to the SSL stream.
Action WriteCommand = delegate(string command)
{
var commandBytes = Encoding.ASCII.GetBytes(command + Environment.NewLine);
sslStream.Write(commandBytes, 0, commandBytes.Length);
};
// Write raw FTP commands to the SSL stream.
WriteCommand("USER username");
WriteCommand("PASS ***p@ssw0rd***");
// Connect to data port to download the file.
}