Quantcast
Channel: Alex FTPS Client
Viewing all 114 articles
Browse latest View live

Created Issue: Connection failure with unaccurate exception [8505]

$
0
0
Hi,
While logging on a ftp server (of which I can't disclose the adress/login, sorry) i've got an accurate exception. Please notice that filezilla also fails to connect to.

This is the stacktrace :
System.ArgumentNullException: La valeur ne peut pas être null.
Nom du paramètre : input
à System.Text.RegularExpressions.Regex.Match(String input)
à System.Text.RegularExpressions.Regex.Match(String input, String pattern)
à AlexPilotti.FTPS.Client.FTPSClient.GetReply()
à AlexPilotti.FTPS.Client.FTPSClient.Connect(String hostname, Int32 port, NetworkCredential credential, ESSLSupportMode sslSupportMode, RemoteCertificateValidationCallback userValidateServerCertificate, X509Certificate x509ClientCert, Int32 sslMinKeyExchangeAlgStrength, Int32 sslMinCipherAlgStrength, Int32 sslMinHashAlgStrength, Nullable`1 timeout, Boolean useCtrlEndPointAddressForData, EDataConnectionMode dataConnectionMode)
à AlexPilotti.FTPS.Client.FTPSClient.Connect(String hostname, Int32 port, NetworkCredential credential, ESSLSupportMode sslSupportMode, RemoteCertificateValidationCallback userValidateServerCertificate, X509Certificate x509ClientCert, Int32 sslMinKeyExchangeAlgStrength, Int32 sslMinCipherAlgStrength, Int32 sslMinHashAlgStrength, Nullable`1 timeout, Boolean useCtrlEndPointAddressForData)
à AlexPilotti.FTPS.Client.FTPSClient.Connect(String hostname, Int32 port, NetworkCredential credential, ESSLSupportMode sslSupportMode, RemoteCertificateValidationCallback userValidateServerCertificate, X509Certificate x509ClientCert, Int32 sslMinKeyExchangeAlgStrength, Int32 sslMinCipherAlgStrength, Int32 sslMinHashAlgStrength, Nullable`1 timeout)
à AlexPilotti.FTPS.Client.FTPSClient.Connect(String hostname, NetworkCredential credential, ESSLSupportMode sslSupportMode, RemoteCertificateValidationCallback userValidateServerCertificate)
à AlexPilotti.FTPS.Client.FTPSClient.Connect(String hostname, NetworkCredential credential, ESSLSupportMode sslSupportMode)

This is the corresponding filezilla verbose log (in french) :
Statut : Résolution de l'adresse de xx
Statut : Connexion à xxx:21...
Statut : Connexion établie, attente du message d'accueil...
Erreur : Délai d'attente expiré
Suivi : CFtpControlSocket::ResetOperation(2114)
Suivi : CControlSocket::ResetOperation(2114)
Erreur : Impossible d'établir une connexion au serveur

The server is pure FTP (no security layer) with login/password.

New Post: Resume on file download?

$
0
0

I found this client very useful but can't figure out how to allow for a partially downloaded file to resume from where it stopped?  CanSeek isn't available on a NetworkStream so I am at a loss what to do.  Any help would be appreciated.  Thanks!!

New Post: Active connection sample

$
0
0

Can someone post some sample code for making an ACTIVE connection. 

New Post: Connecting to OracleDB Repository

$
0
0

I want to include that my Z/OS (MVS) system also returns the FEAT  without an END so I also receive the OutOfRangeException. I am including the portion of the log that shows the FEAT. Thanks a million for working on this I love your Class Library.

 

Status: Resolving address of my.website.com
Status: Connecting to nn.nn.nn.nn:21...
Status: Connection established, waiting for welcome message...
Response: 220-FTPD1 IBM FTP CS V1R11 at my.website.com, 14:33:20 on 2013-01-26.
Response: 220 Connection will close if idle for more than 15 minutes.
Command: USER thisisme
Response: 331 Send password please.
Command: PASS ******
Response: 230 thisisme is logged on.  Working directory is "thisisme.".
Command: SYST
Response: 215 MVS is the operating system of this server. FTP Server is running on z/OS.
Command: FEAT
Response: 211 no Extensions supported
Status: Server does not support non-ASCII characters.
Status: Connected
Status: Retrieving directory listing...

 

 

Commented Issue: FEAT 211 No extension supported [8218]

$
0
0
<p>I have a server that responds to the FEAT command with &quot;211 No extension supported&quot;, causing</p>
<p>&#160;</p>
<p>System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.</p>
<p>Parameter name: index</p>
<p> at System.Collections.Generic.List`1.RemoveAt(Int32 index)</p>
<p> at AlexPilotti.FTPS.Client.FTPSClient.GetFeaturesFromServer()</p>
<p> at AlexPilotti.FTPS.Client.FTPSClient.Connect(String hostname, Int32 port, NetworkCredential credential, ESSLSupportMode sslSupportMode, RemoteCertificateValidationCallback userValidateServerCertificate, X509Certificate x509ClientCert, Int32 sslMinKeyExchangeAlgStrength, Int32 sslMinCipherAlgStrength, Int32 sslMinHashAlgStrength, Nullable`1 timeout, Boolean useCtrlEndPointAddressForData, EDataConnectionMode dataConnectionMode)</p>
Comments: ** Comment from web user: rsjrny **

My MVS (Z/OS) system returns the same FEAT and is causing me a connection problem.


Status: Resolving address of my.website.com
Status: Connecting to nn.nn.nn.nn:21...
Status: Connection established, waiting for welcome message...
Response: 220-FTPD1 IBM FTP CS V1R11 at my.website.com, 14:33:20 on 2013-01-26.
Response: 220 Connection will close if idle for more than 15 minutes.
Command: USER thisisme
Response: 331 Send password please.
Command: PASS ******
Response: 230 thisisme is logged on. Working directory is "thisisme.".
Command: SYST
Response: 215 MVS is the operating system of this server. FTP Server is running on z/OS.
Command: FEAT
Response: 211 no Extensions supported
Status: Server does not support non-ASCII characters.
Status: Connected
Status: Retrieving directory listing...

New Post: Preserve File Date/Time Stamp

$
0
0
<div dir="ltr">Thank you very much Gregory. I will try it at work tomorrow and see if I can get it to work.<div><br></div><div>Very sorry for the late response, it went to a junk email on a email account I rarely use.</div><div><br></div><div>Thanks Again</div><div>Greg (also)<br><br><div><div id="SkyDrivePlaceholder"></div><hr id="stopSpelling"> From: [email removed]<br> To: [email removed]<br> Date: Thu, 8 Nov 2012 07:57:53 -0800<br> Subject: Re: Preserve File Date/Time Stamp [ftps:394681]<br><br> From: gregorysch<br><div id="ecxThreadNotificationPostBody">In the System.IO namespace, you can use the following instructions:<br><ul><li>File.SetCreationTime(filename, dateInfo) </li><li>File.SetLastWriteTime(filename, dateInfo) </li></ul> You can reuse for &quot;dateInfo&quot; parameter the information that you find in &quot;<strong><em>&#65279;DirectoryListItem</em></strong>&quot; class, the &quot;<strong><em>CreationTime</em></strong>&quot; field.<br> Hope it helps,<br> Greg.<br><br><br><br><br><br>&#65279;&#65279;&#65279;<br></div><div id="ecxThreadNotificationFooter">Read the <a href="http://ftps.codeplex.com/discussions/394681#post938588" target="_blank"> full discussion online</a>.<br> To add a post to this discussion, reply to this email (<a href="mailto:ftps@discussions.codeplex.com?subject=[ftps:394681]">ftps@discussions.codeplex.com</a>)<br> To start a new discussion for this project, email <a href="mailto:ftps@discussions.codeplex.com"> ftps@discussions.codeplex.com</a><br> You are receiving this email because you subscribed to this discussion on CodePlex. You can<a href="https://ftps.codeplex.com/discussions/394681/unsubscribe/" target="_blank"> unsubscribe</a> on CodePlex.com.<br> Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com<br></div></div></div></div>

New Post: Clear Control Channel using binary client

$
0
0
Hello,

I try to use binary client in a TLS authentication with clear command and data mode but couldn't achieve it.

I use -tls CredentialsRequired option but control channel is not switching to clear, data only.

My session log shows no CCC command from client.

Could you please advice, I'm new to Alex FTPS maybe i missed something.

Thanks a lot for your help,

Herve

New Post: GetFile returns ulong

$
0
0
Can somebody help me with the GetFile(source, destination) method? The return value is ulong. What does the value signify? If it returns 0, does it mean the operation failed? Just need to clarify.

Patch Uploaded: #14032

$
0
0

harshdeep has uploaded a patch.

Description:
Patch to replace properties with AutoProperty, and added some comments.

Updated Wiki: Home

$
0
0

Project Description


This projects provides a free FTP/FTPS client and class library available on any platform supporting the.Net Framework 2.0 or Mono 2.0. This currently includes: Microsoft Windows 2000 SP4/XP SP2/2003/Vista/2008, Linux, Mac OS X 10.4 and above, and, to some extent, Sun Solaris.

Please see http://www.mono-project.com for a complete list of platforms supported by Mono 2.0.

Implemented RFCs:

959, 2228, 2389, 2428, 2640, 3659, 4217

FTPS (sometimes called FTPES or explicit FTPS) is implemented as described in the RFC 4217 and RFC 2228 documents.http://www.ietf.org/rfc/rfc4217.txt Support for the so calledimplicit FTPS has also been added (although not standard).

FTPS should not be confused with SFTP (FTP over SSH).

For more information please see http://en.wikipedia.org/wiki/FTPS

Note: not all the FTP commands described in the RFC documents are curently implemented (some of them are obsolete, others were not necessary for the purposes of this project). Please seeImplemented FTP commands below for a detailed list of implemeted commands

Follow alexpilotti on Twitter

CBSLogo_thumb.png

The FTP/FTPS Client

The aim of this FTP/FTPS client is to support the advanced features provided by most modern FTP servers, primarily, but not limited to,encryption via SSL/TLS and UTF8. A list of the implemented RFC standards and specific commands follows.

The idea of this client was born while preparing some material for a technical speech session I was going to give at theItalian Microsoft TechDays - WPC 2008, about IIS 7.0 new features, including theMicrosoft FTP for IIS 7.0 add in and its freshly introduced support for SSL/TLS.

One of the main problems with standard FTP communications, is that all the username / password communication is performed in clear text, easily eavesdropped by sniffing the network traffic. Altough FTP is one of the oldest Internet protocols still in use today, some of its features are still largely needed as they can't be easily replaced by, for example, an HTTP server.

The SSL/TLS encryption feature, as stated in the RFC 4217 document http://www.ietf.org/rfc/rfc4217.txt, provides a solution for this and other security related limitations. Support for SSL/TLS has been introduced in the most used FTP servers:Microsoft FTP for IIS 7.0, vsftpd, wu-ftpd, FileZilla server, to name a few. Note: vsftpd FTPS support requires version 2.1.0 or a smallpatch for version 2.0.7.

Looking for a free client to be used during my session demos, showing interoperability with other platforms, I realized that there was no single piece of software supporting all the features I needed. Furthermore, I wanted to provide a sample on how to connect to a FTP server using SSL using Microsoft .Net and the Powershell, but the standardSystem.Net.FTPWebRequest provided by the framework was not powerful enough (more on this below).

That was enough to start this project. The client provides also a wide range of options and commands via command line arguments,making it fully functional when used in scripts, without the shortcomings of the standard FTP clients available on most platforms.

Portability among platforms (via the .Net Framework 2.0 and Mono 2.0) and compatibility with all the relevant FTPS servers is also a mandatory goal for this project.

Please see below for some Quick usage samples and the fullCommand line reference.

Microsoft Powershell integration

The development of specifc CmdLets is in progress. Please stay tuned.

Portable GUI

A free portable GUI is also planned and will be developed if there's enough feedback on the project.

Quick usage samples

Note: execute mono ftps.exe <arguments> when using Mono.

  • Show the directory contents of a remote directory using anonymous authentication on standard FTP (without SSL/TLS):

 

ftps -h ftp.yourserver.com -ssl ClearText -l /pub
  • Connect to the server using SSL/TLS during authentication or clear text mode (standard FTP) if FTPS is not supported:

 

ftps -h ftp.yourserver.com -U alex -l /some/path/
  • Connect to the server using SSL/TLS on the control channel, accepting invalid certificates without prompting:

 

ftps -h ftp.yourserver.com -U alex -ssl ControlChannelRequired 
     -sslInvalidServerCertHandling Accept -l /some/path
  • Download a remote file using control and data channel SSL/TLS encryption:

 

ftps -h ftp.yourserver.com -U alex -ssl DataChannelRequired 
     -g /remote/path/somefile.txt /local/path/
  • Upload a local file with a control channel encrypted during authentication only:

 

ftps -h ftp.yourserver.com -U alex -ssl CredentialsRequired 
     -p /local/path/somefile.txt /remote/path/
  • Recursively download a whole directory tree:

 

ftps -h ftp.yourserver.com -r -g /remote/path/* \local\path\
  • Export the server's X.509 certificate on a FTPS connection:

 

ftps -h ftp.yourserver.com -U alex -expCert serverCert.cer
  • Implicit FTPS connection on port 21:

 

ftps -h ftp.yourserver.com -U alex -port 21 -ssl Implicit -l


Command line reference

The command line reference, available by executing ftps -? or mono ftps.exe -? using Mono, follows:

Usage: ftps [options] <command> [command specific arguments]



Commands:

-?, -help

Shows help and usage info

-d, -delete

Deletes a remote file

-expCert, -exportSslServerCert

Exports the server's SSL/TLS X.509 certificate. The export format is managed by the "sslX509ExportFormat" option

-f, -features

Prints the list of features supported by the server, as returned by the FTP FEAT command

-g, -get, -download

Downloads the given files in the current directory. File names may include wildcards. Operates recursively if the "r" option is specified

-l, -list

Returns the contents of the given directory, or the default directory if no name is provided

-md, -mkdir

Creates a remote directory

-p, -put, -upload

Uploads the given files or directory contents. File names may include wildcards. Operates recursively if the "r" option is specified

-pa, -putAppend

Uploads a file appending it's contents if the given remote file already exists

-pu, -putUnique

Uploads a file with a unique name

-rd, -rmdir

Removes a remote directory

-rn, -rename

Renames a remote file

-sys, -system

Returns a brief description of the remote system

-cust, -custom

Sends the given FTP command to the server. Note: only the control channel reply is returned


Generic options:

-dm, -dataMode

Active or Passive (default) data connection mode

-h, -hostname

Name or IP address of the remote host to connect to

-lf, -logFile

ftp commands and server replies log file name

-ltfs, -logFileTimeStamp

Adds a timestamp to every command and reply in the log file

-noCopyrightInfo

Avoids displaying the copyright information header

-oda, -overrideDataAddress

Use the control connection's remote address instead of the one returned by the PASV command

-P, -password

Password to be used in case of non anonymous connections. If omitted it will be requested before connecting. Passing this information as a command line parameter is strongly discouraged for security reasons

-port

TCP/IP connection port, default is: 21 for standard FTP or explicit FTPS, 990 for implicit FTPS

-r, -recursive

Enable recursion to download or upload entire directory trees

-t, -timeout

TCP/IP connection timeout in seconds (default 120s)

-tm, -transferMode

Transfer mode / representation type. "ASCII" or "Binary" (default)

-U, -username

Username used to perform the connection. If omitted an anonymous connection will be performed

-v, -verbose

Verbose output


SSL/TLS specific options:

-ssl, -tls

SSL/TLS support. Possible values are:

  • ClearText (Standard FTP, no SSL/TLS support)
  • CredentialsRequested
  • CredentialsRequired
  • ControlChannelRequested
  • ControlChannelRequired
  • DataChannelRequested (Default)
  • DataChannelRequired
  • ControlAndDataChannelsRequested
  • ControlAndDataChannelsRequired (most secure)
  • All (alias for ControlAndDataChannelsRequired)
  • Implicit


-sslClientCertPath

X.509 client certificate file path

-sslInvalidServerCertHandling

Invalid X.509 server certificate handling. Valid values are:

  • Accept
  • Prompt (default)
  • Refuse


-sslMinCipherStrength

Min. cipher algorithm strength (e.g: 168). Default is 0

-sslMinHashStrength

Min. hash algorithm strength (e.g: 160). Default is 0

-sslMinKeyExStrength

Min. key exchange algorithm strength (e.g: 1024). Default is 0

-sslX509ExportFormat

X509 certificate export format. Not all formats are available on all platforms. Supported values are:

  • Cert (default)
  • Pkcs12
  • SerializedCert

The FTP/FTPS class library

The System.Net.FTPWebRequest class provided by the .Net Framework, is perfect for simple tasks (e.g. downloading or uploading a file or getting a directory list) and supports also SSL via theEnableSsl property See: http://blogs.msdn.com/adarshk/archive/2005/04/22/410925.aspx . So why a new class for that?

The point is that SSL support in FTP is more that an on/off switch (as in HTTP/HTTPS). FTP requires two separate connections: one for the commands (thecontrol connection) and one for the data (thedata connection), for downloads, uploads and directory listings.
FTPWebRequest.EnableSsl simply forces the use of SSL on both of them. The problem is that this is not always suitable.

FTP connections are tipically a pain for firewalls, because the control connection uses a standard TCP port (21), but data connections (in so calledpassive mode), tipically listen on a random port, communicated to the client on the control channel. Well, if the connection is not encrypted, as in standard FTP, firewalls are able to do some packet inspection, get the port number sent to the client and allow the connection from that client to the server. To cut a long story short, encrypting the control channel means that firewalls will not be able to do packet inspections and, you guessed it, this is where the problems begin. Please seehttp://en.wikipedia.org/wiki/FTPS for more on the subject.

There's a partial solution to this problem:

Encrypting the control channel during the credentials exchange (USER/PASS commands) and reverting to clear text after that. This is of course far below the goals of the SSL/TLS support, but it's enough for a very large number of needs and is supported by all the main FTPS servers.

This class library provides a number of SSL/TLS related options to deal with this and other issues.

Aside that, the class library provides support for a large number of standard FTP commands and some very useful features:

  • Tracking of the download status via delegate based callbacks (useful to display the download/upload progress)
  • Recursive directory trees downloads and uploads
  • Support for UTF8 in commands and directory listings (by explicitly setting OPTS UTF8 ON if available in the features returned by the FEAT command)
  • IPV6 support (planned)
  • Multi platform (Microsoft Windows, Linux, Mac OS X, did I already said that?) ;-)


The full MSDN style documentation will be released shortly.

In order to use the FTPS class library, add the AlexPilotti.FTPS.Client.dll assembly to your project References.
The assembly is available along with the FTPS client on the Releases page.

The class library is distributed as free software and can be freely used in your projects, under the terms of the LGPL license.

Simple class library usage sample in C# (any other CLR compliant language is also supported, e.g.: VB.Net, C++/CLI, etc.):

using AlexPilotti.FTPS.Client;
using AlexPilotti.FTPS.Common;
using System.Net;


class Test
{
    publicstaticvoid Main()
    {
        using (FTPSClient client = new FTPSClient())
        {
            // Connect to the server, with mandatory SSL/TLS // encryption during authentication and // optional encryption on the data channel // (directory lists, file transfers)
            client.Connect("ftp.yourserver.com", 
                           new NetworkCredential("yourUsername", 
                                                 "yourPassword"), 
                           ESSLSupportMode.CredentialsRequired | 
                           ESSLSupportMode.DataChannelRequested);
			
            // Download a file
            client.GetFile("/path/to/remotefile.jpg", "c:\\local\\path\\");
        }
    }
}

Snapshots

AlexFTPS on Windows Vista:

This screenshots shows the transfer status available during downloads / uploads.

ftps_Vista_640.png

AlexFTPS on Linux:

ftps_Linux_640.png

AlexFTPS on Mac OS X:

ftps_Mac_OS_X.png

Implemented FTP commands

Note: RFC 959 is listed also for commands introduced in previous documents.

Command name Notes RFC
APPE 959
AUTHTLS supported2228
CCC 2228
CDUP 959
CLNTRequired by some servers?
CWD 959
DELE 959
FEAT 2389
LANG 2640
LIST 959
MDTM 3659
MKD 959
NLST 959
NOOP 959
OPTSMainly UTF8 support2389
PASS 959
PASV 959
PROTPROT P, C support2228
PSBZ 2228
PWD 959
QUIT 959
RETR 959
RMD 959
RNFR 959
RNTO 959
SIZE 3659
STOR 959
STOU 959
SYST 959
TYPEASCII and Image (Binary) representation types supported959
USER 959

 

NUnit tests

Will be posted shortly!

TODO

Here's the list of things that need to be implemented.

  • Proxy support
  • More RFC 2228 commands
  • Internationalization

vsftpd patch

There is a small bug in vsftpd 2.0.7 related to OpenSSL contexts, confirmed by the author and solved in version 2.1.0 which prevents full SSL/TLS compatibility.
Here's a workaround for version 2.0.7. Just apply this patch to ssl.c: vsftpd-2.0.7-ssl-diff.txt It's just 3 lines of code! :-)
Please note: this is an unofficial patch.


Well, that's all by now. Please provide your comments, feature requests, bug reports, etc. on the Discussion page.



Alessandro Pilotti
MVP / IIS

MVP_Horizontal_FullColor_small.png

Updated Wiki: Home

$
0
0

Project Description


This projects provides a free FTP/FTPS client and class library available on any platform supporting the.Net Framework 2.0 or Mono 2.0. This currently includes: Microsoft Windows 2000 SP4/XP SP2/2003/Vista/2008, Linux, Mac OS X 10.4 and above, and, to some extent, Sun Solaris.

Please see http://www.mono-project.com for a complete list of platforms supported by Mono 2.0.

Implemented RFCs:

959, 2228, 2389, 2428, 2640, 3659, 4217

FTPS (sometimes called FTPES or explicit FTPS) is implemented as described in the RFC 4217 and RFC 2228 documents.http://www.ietf.org/rfc/rfc4217.txt Support for the so calledimplicit FTPS has also been added (although not standard).

FTPS should not be confused with SFTP (FTP over SSH).

For more information please see http://en.wikipedia.org/wiki/FTPS

Note: not all the FTP commands described in the RFC documents are curently implemented (some of them are obsolete, others were not necessary for the purposes of this project). Please seeImplemented FTP commands below for a detailed list of implemeted commands

Follow alexpilotti on Twitter

CBSLogo_thumb.png

The FTP/FTPS Client

The aim of this FTP/FTPS client is to support the advanced features provided by most modern FTP servers, primarily, but not limited to,encryption via SSL/TLS and UTF8. A list of the implemented RFC standards and specific commands follows.

The idea of this client was born while preparing some material for a technical speech session I was going to give at theItalian Microsoft TechDays - WPC 2008, about IIS 7.0 new features, including theMicrosoft FTP for IIS 7.0 add in and its freshly introduced support for SSL/TLS.

One of the main problems with standard FTP communications, is that all the username / password communication is performed in clear text, easily eavesdropped by sniffing the network traffic. Altough FTP is one of the oldest Internet protocols still in use today, some of its features are still largely needed as they can't be easily replaced by, for example, an HTTP server.

The SSL/TLS encryption feature, as stated in the RFC 4217 document http://www.ietf.org/rfc/rfc4217.txt, provides a solution for this and other security related limitations. Support for SSL/TLS has been introduced in the most used FTP servers:Microsoft FTP for IIS 7.0, vsftpd, wu-ftpd, FileZilla server, to name a few. Note: vsftpd FTPS support requires version 2.1.0 or a smallpatch for version 2.0.7.

Looking for a free client to be used during my session demos, showing interoperability with other platforms, I realized that there was no single piece of software supporting all the features I needed. Furthermore, I wanted to provide a sample on how to connect to a FTP server using SSL using Microsoft .Net and the Powershell, but the standardSystem.Net.FTPWebRequest provided by the framework was not powerful enough (more on this below).

That was enough to start this project. The client provides also a wide range of options and commands via command line arguments,making it fully functional when used in scripts, without the shortcomings of the standard FTP clients available on most platforms.

Portability among platforms (via the .Net Framework 2.0 and Mono 2.0) and compatibility with all the relevant FTPS servers is also a mandatory goal for this project.

Please see below for some Quick usage samples and the fullCommand line reference.

Microsoft Powershell integration

The development of specifc CmdLets is in progress. Please stay tuned.

Portable GUI

A free portable GUI is also planned and will be developed if there's enough feedback on the project.

Quick usage samples

Note: execute mono ftps.exe <arguments> when using Mono.

  • Show the directory contents of a remote directory using anonymous authentication on standard FTP (without SSL/TLS):

 

ftps -h ftp.yourserver.com -ssl ClearText -l /pub
  • Connect to the server using SSL/TLS during authentication or clear text mode (standard FTP) if FTPS is not supported:

 

ftps -h ftp.yourserver.com -U alex -l /some/path/
  • Connect to the server using SSL/TLS on the control channel, accepting invalid certificates without prompting:

 

ftps -h ftp.yourserver.com -U alex -ssl ControlChannelRequired 
     -sslInvalidServerCertHandling Accept -l /some/path
  • Download a remote file using control and data channel SSL/TLS encryption:

 

ftps -h ftp.yourserver.com -U alex -ssl DataChannelRequired 
     -g /remote/path/somefile.txt /local/path/
  • Upload a local file with a control channel encrypted during authentication only:

 

ftps -h ftp.yourserver.com -U alex -ssl CredentialsRequired 
     -p /local/path/somefile.txt /remote/path/
  • Recursively download a whole directory tree:

 

ftps -h ftp.yourserver.com -r -g /remote/path/* \local\path\
  • Export the server's X.509 certificate on a FTPS connection:

 

ftps -h ftp.yourserver.com -U alex -expCert serverCert.cer
  • Implicit FTPS connection on port 21:

 

ftps -h ftp.yourserver.com -U alex -port 21 -ssl Implicit -l


Command line reference

The command line reference, available by executing ftps -? or mono ftps.exe -? using Mono, follows:

Usage: ftps [options] <command> [command specific arguments]



Commands:

-?, -help

Shows help and usage info

-d, -delete

Deletes a remote file

-expCert, -exportSslServerCert

Exports the server's SSL/TLS X.509 certificate. The export format is managed by the "sslX509ExportFormat" option

-f, -features

Prints the list of features supported by the server, as returned by the FTP FEAT command

-g, -get, -download

Downloads the given files in the current directory. File names may include wildcards. Operates recursively if the "r" option is specified

-l, -list

Returns the contents of the given directory, or the default directory if no name is provided

-md, -mkdir

Creates a remote directory

-p, -put, -upload

Uploads the given files or directory contents. File names may include wildcards. Operates recursively if the "r" option is specified

-pa, -putAppend

Uploads a file appending it's contents if the given remote file already exists

-pu, -putUnique

Uploads a file with a unique name

-rd, -rmdir

Removes a remote directory

-rn, -rename

Renames a remote file

-sys, -system

Returns a brief description of the remote system

-cust, -custom

Sends the given FTP command to the server. Note: only the control channel reply is returned


Generic options:

-dm, -dataMode

Active or Passive (default) data connection mode

-h, -hostname

Name or IP address of the remote host to connect to

-lf, -logFile

ftp commands and server replies log file name

-ltfs, -logFileTimeStamp

Adds a timestamp to every command and reply in the log file

-noCopyrightInfo

Avoids displaying the copyright information header

-oda, -overrideDataAddress

Use the control connection's remote address instead of the one returned by the PASV command

-P, -password

Password to be used in case of non anonymous connections. If omitted it will be requested before connecting. Passing this information as a command line parameter is strongly discouraged for security reasons

-port

TCP/IP connection port, default is: 21 for standard FTP or explicit FTPS, 990 for implicit FTPS

-r, -recursive

Enable recursion to download or upload entire directory trees

-t, -timeout

TCP/IP connection timeout in seconds (default 120s)

-tm, -transferMode

Transfer mode / representation type. "ASCII" or "Binary" (default)

-U, -username

Username used to perform the connection. If omitted an anonymous connection will be performed

-v, -verbose

Verbose output


SSL/TLS specific options:

-ssl, -tls

SSL/TLS support. Possible values are:

  • ClearText (Standard FTP, no SSL/TLS support)
  • CredentialsRequested
  • CredentialsRequired
  • ControlChannelRequested
  • ControlChannelRequired
  • DataChannelRequested (Default)
  • DataChannelRequired
  • ControlAndDataChannelsRequested
  • ControlAndDataChannelsRequired (most secure)
  • All (alias for ControlAndDataChannelsRequired)
  • Implicit


-sslClientCertPath

X.509 client certificate file path

-sslInvalidServerCertHandling

Invalid X.509 server certificate handling. Valid values are:

  • Accept
  • Prompt (default)
  • Refuse


-sslMinCipherStrength

Min. cipher algorithm strength (e.g: 168). Default is 0

-sslMinHashStrength

Min. hash algorithm strength (e.g: 160). Default is 0

-sslMinKeyExStrength

Min. key exchange algorithm strength (e.g: 1024). Default is 0

-sslX509ExportFormat

X509 certificate export format. Not all formats are available on all platforms. Supported values are:

  • Cert (default)
  • Pkcs12
  • SerializedCert

The FTP/FTPS class library

The System.Net.FTPWebRequest class provided by the .Net Framework, is perfect for simple tasks (e.g. downloading or uploading a file or getting a directory list) and supports also SSL via theEnableSsl property See: http://blogs.msdn.com/adarshk/archive/2005/04/22/410925.aspx . So why a new class for that?

The point is that SSL support in FTP is more that an on/off switch (as in HTTP/HTTPS). FTP requires two separate connections: one for the commands (thecontrol connection) and one for the data (thedata connection), for downloads, uploads and directory listings.
FTPWebRequest.EnableSsl simply forces the use of SSL on both of them. The problem is that this is not always suitable.

FTP connections are tipically a pain for firewalls, because the control connection uses a standard TCP port (21), but data connections (in so calledpassive mode), tipically listen on a random port, communicated to the client on the control channel. Well, if the connection is not encrypted, as in standard FTP, firewalls are able to do some packet inspection, get the port number sent to the client and allow the connection from that client to the server. To cut a long story short, encrypting the control channel means that firewalls will not be able to do packet inspections and, you guessed it, this is where the problems begin. Please seehttp://en.wikipedia.org/wiki/FTPS for more on the subject.

There's a partial solution to this problem:

Encrypting the control channel during the credentials exchange (USER/PASS commands) and reverting to clear text after that. This is of course far below the goals of the SSL/TLS support, but it's enough for a very large number of needs and is supported by all the main FTPS servers.

This class library provides a number of SSL/TLS related options to deal with this and other issues.

Aside that, the class library provides support for a large number of standard FTP commands and some very useful features:

  • Tracking of the download status via delegate based callbacks (useful to display the download/upload progress)
  • Recursive directory trees downloads and uploads
  • Support for UTF8 in commands and directory listings (by explicitly setting OPTS UTF8 ON if available in the features returned by the FEAT command)
  • IPV6 support (planned)
  • Multi platform (Microsoft Windows, Linux, Mac OS X, did I already said that?) ;-)


The full MSDN style documentation will be released shortly.

In order to use the FTPS class library, add the AlexPilotti.FTPS.Client.dll assembly to your project References.
The assembly is available along with the FTPS client on the Releases page.

The class library is distributed as free software and can be freely used in your projects, under the terms of the LGPL license.

Simple class library usage sample in C# (any other CLR compliant language is also supported, e.g.: VB.Net, C++/CLI, etc.):

using AlexPilotti.FTPS.Client;
using AlexPilotti.FTPS.Common;
using System.Net;


class Test
{
    publicstaticvoid Main()
    {
        using (FTPSClient client = new FTPSClient())
        {
            // Connect to the server, with mandatory SSL/TLS // encryption during authentication and // optional encryption on the data channel // (directory lists, file transfers)
            client.Connect("ftp.yourserver.com", 
                           new NetworkCredential("yourUsername", 
                                                 "yourPassword"), 
                           ESSLSupportMode.CredentialsRequired | 
                           ESSLSupportMode.DataChannelRequested);
			
            // Download a file
            client.GetFile("/path/to/remotefile.jpg", "c:\\local\\path\\");
        }
    }
}

Snapshots

AlexFTPS on Windows:

This screenshots shows the transfer status available during downloads / uploads.

ftps_Vista_640.png

AlexFTPS on Linux:

ftps_Linux_640.png

AlexFTPS on Mac OS X:

ftps_Mac_OS_X.png

Implemented FTP commands

Note: RFC 959 is listed also for commands introduced in previous documents.

Command name Notes RFC
APPE 959
AUTHTLS supported2228
CCC 2228
CDUP 959
CLNTRequired by some servers?
CWD 959
DELE 959
FEAT 2389
LANG 2640
LIST 959
MDTM 3659
MKD 959
NLST 959
NOOP 959
OPTSMainly UTF8 support2389
PASS 959
PASV 959
PROTPROT P, C support2228
PSBZ 2228
PWD 959
QUIT 959
RETR 959
RMD 959
RNFR 959
RNTO 959
SIZE 3659
STOR 959
STOU 959
SYST 959
TYPEASCII and Image (Binary) representation types supported959
USER 959

 

NUnit tests

Will be posted shortly!

TODO

Here's the list of things that need to be implemented.

  • Proxy support
  • More RFC 2228 commands
  • Internationalization

vsftpd patch

There is a small bug in vsftpd 2.0.7 related to OpenSSL contexts, confirmed by the author and solved in version 2.1.0 which prevents full SSL/TLS compatibility.
Here's a workaround for version 2.0.7. Just apply this patch to ssl.c: vsftpd-2.0.7-ssl-diff.txt It's just 3 lines of code! :-)
Please note: this is an unofficial patch.


Well, that's all by now. Please provide your comments, feature requests, bug reports, etc. on the Discussion page.



Alessandro Pilotti
MVP / IIS

MVP_Horizontal_FullColor_small.png

New Post: SSL/TLS authentication not allowed

$
0
0
Hi,

I'm trying to make example work from home page on c#:
using (FTPSClient client = new FTPSClient())
            {
                client.Connect("172.16.17.15",
                               new NetworkCredential("test",  "test"),
                               ESSLSupportMode.CredentialsRequired |
                               ESSLSupportMode.DataChannelRequested);

                client.GetFile("/it/remotefile.jpg", @"c:\temp\");
But I'm getting error like "SSL/TLS authentication not allowed" any one knows hot to solve this issue or change authentication? Then I'm connecting through Total Commander I'm getting log like this maybe it will help:
QUIT
221 Goodbye
----------
Connect to: (18/03/2013 15:21:39)
hostname=172.16.17.15
username=test
startdir=
172.16.17.15=172.16.17.15
220 FileZilla Server version 0.9.39 beta
USER test
331 Password required for test
PASS ***********
230 Logged on
SYST
215 UNIX emulated by FileZilla
FEAT
211-Features:
 MDTM
 REST STREAM
 SIZE
 MLST type*;size*;modify*;
 MLSD
 UTF8
 CLNT
 MFMT
211 End
CLNT Total Commander (UTF-8)
200 Don't care
OPTS UTF8 ON
200 UTF8 mode enabled
Connect ok!
PWD
257 "/" is current directory.
Get directory
TYPE A
200 Type set to A
PORT 192,168,1,233,17,224
200 Port command successful
MLSD
150 Opening data channel for directory list.
Download
Waiting for server...
226 Transfer OK
I try to find some documentation and samples of this library but failed.

Thanks

New Post: The remote certificate is invalid according to the validation procedure

$
0
0
We have a Test Environment where we test out programs and then deploy it in production.
One program utilizes your library (Thanks for that !!!) and runs just fine using the following code:
        using (FTPSClient client = new FTPSClient())
        {
            client.Connect(FTPSite, credential, ESSLSupportMode.CredentialsRequired | ESSLSupportMode.DataChannelRequested, new RemoteCertificateValidationCallback(ValidateTestServerCertificate));
            LSOutput = client.GetDirectoryListUnparsed(FTPFolder);
        }
When the same code was deployed in Production, I got this error:
"The remote certificate is invalid according to the validation procedure"

In Test Region it did not give any certificate error and in Prod it started giving.

So I had to use the logic of accepting all certificates. So It started working fine. But its exceptionally slow. Takes 1 min to connect and another 1 min to retrive Directory listing.

Can you help me debug the issue.

New Post: Control the bandwidth

$
0
0
Hi,
Is there a way to control / limit the bandwidth speed?

THX!

New Post: No luck in connecting to Implicit FTP, ask for help


New Post: No luck in connecting to Implicit FTP, ask for help

New Post: connect to sftp with proxy

$
0
0
Hi,

i am using Alex ftp client and want to connect with sftp (SSH) file transfer using the Proxy.

Is this utility support this feature? Please let me know.

Thanks,
Sunil

New Post: connect to sftp with proxy

$
0
0
Hi,

Sftp is a completely different protocol, not supported by our ftps client.

New Post: How to know the size of files?

$
0
0
A new DLL would be very helpful. I just started writing an app and got around to using DirectoryListItem and found out that 1.1.0 doesn't include the Size property so I'm kinda stalled right now.

Created Issue: Mocking capabilities [8722]

$
0
0
Hello,

I am coding a project using Alex FTPS Client as a library to provide FTP capabilities.

I use MoQ to unit test my code, but i can't mock FTPSClient. The problem is most of mocking libraries need the mocked code to be an interface, an abstract or non-sealed class.

Would it be possible to make Alex FTPS Client mockable ?

Thanks
Viewing all 114 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>