edtFTPnet/PRO - Secure FTP component for .NET | Free Trial | Pricing

SSLFTPClient Class

Provides low-level access to FTP/FTPS functionality.

Definition

Namespace: EnterpriseDT.Net.Ftp.Ssl
Assembly: edtFTPnetPRO (in edtFTPnetPRO.dll) Version: 12.7.0.0
C#
public class SSLFTPClient : ExFTPClient
Inheritance
Object    FTPClient    ExFTPClient    SSLFTPClient

Remarks

SSLFTPClient supports SOCKS (4, 4A, and 5) and FTPS (implicit and explicit).

FTPS: SSLFTPClient supports standard FTP and the two types of FTPS, explicit and implicit. The default is explicit FTPS. The type may be selected using the IsImplicitFTPS flag.

Explicit FTPS: The FTP client connects in plain (non-SSL) mode and operates in this mode until the AUTH command is issued by means of the >Auth(string) method. This will cause the client and server to negotiate an SSL connection. Once complete, all commands sent from the client to the server, and their corresponding replies will be secure.

Example

This example shows a simple explicit FTPS session.
C#
// create an explicit FTPS client
SSLFTPClient ftp = new SSLFTPClient();
ftp.RemoteHost = "192.168.10.123";

// Turn off server validation (ONLY do this when testing)
ftp.ServerValidation = SecureFTPServerValidationType.None;

// connect to the server
ftp.Connect();                        

// switch to secure command channel
ftp.Auth(SSLFTPClient.AUTH_TLS);

// log in
ftp.Login("test", "test");

// get a file
ftp.Get("file.txt", "file.txt");

// close the connection
ftp.Quit();

This example uses no client authentication and does not attempt to verify server certificates (which should always be done in production systems).

Implicit FTPS is an older form of FTPS which uses pure SSL connection, i.e. SSL sessions are established immediately upon socket connection for all FTP channels.

Example

This example shows a simple implicit FTPS session:
C#
// create an implicit FTPS client
SSLFTPClient ftp = new SSLFTPClient();
ftp.RemoteHost = "192.168.10.123";

// Turn off server validation (ONLY do this when testing)
ftp.ServerValidation = SecureFTPServerValidationType.None;

// Select implicit FTPS
ftp.IsImplicitFTPS = true;

// connect to the server
ftp.Connect();                        

// log in
ftp.Login("test", "test");

// get a file
ftp.Get("file.txt", "file.txt");

// close the connection
ftp.Quit();

Like the previous example, this example uses no client authentication and does not attempt to verify server certificates (which should be done in production systems).

SSL Certificates - Server Validation: The examples above used no server validation. This is only normally acceptable only when testing. To be secure applications should always validate the server that they're communicating with. If the ServerValidation property is set to SecureFTPServerValidationType.Automatic or SecureFTPServerValidationType.AutomaticIgnoreHostName then SSLFTPClient will attempt to validate the server's certificate. In explicit FTPS this occurs when the Auth(SecurityMechanism) method is invoked, whereas in implicit FTPS, it occurs upon connection. Windows Internet security services are used to validate the certificate. This means that one of the following must be true

  1. CA certificate – The server's certificate must have been issued by a CA (Certificate Authority) whose certificate is in the Windows certificate store.
  2. Non-CA certificate – The server's certificate must be in the Windows certificate store. A certificate may be installed on the system using the Internet Properties settings, which may be accessed from the Windows Control Panel.

SSL Certificates - Client Validation: Some FTPS servers require a client certificate to be presented at the time security information is exchanged. To enable this feature you must set the ClientCertificate property. Certificates may be loaded using a range of static methods in SSLFTPCertificate.

Server Compatibility: The most severe barrier to server compatilibilty is the lack of FTPS support on the server. Most FTP servers can be configured to support FTPS, but some only support SFTP (SSH File Transfer Protocol), which in fact is not FTP in the conventional sense. SFTP is not supported by SSLFTPClient.

The second most common server incompatibility problem is caused by differing level of adherence to the standard for how SSL/TLS sockets should be closed. By default SSLFTPClient will attempt to close sockets in the standards-compliant way. While this is the most secure, it occasionally will cause hanging as it waits for a response from the client which never arrives. The ServerCompatibility property is provided for controlling this behaviour. If you experience hanging when a data-transfer is complete then you should first try SecureFTPCompatibilityFlags.SSLDisableDataWaitOnClose and, if the problem still occurs, SecureFTPCompatibilityFlags.SSLDisableDataClosure. If you experience hanging as you close your secure FTP session then you should first try SecureFTPCompatibilityFlags.SSLDisableControlWaitOnClose and, if the problem still occurs, SecureFTPCompatibilityFlags.SSLDisableControlClosure.

Cipher-Suites: A cipher-suite is a set of algorithms that is used for various aspects of SSL security. For a client and a server to be able to communicate, they must be able to agree on a particular cipher-suite. Different types of servers recognize different cipher-suites, so it is usually up to the client make sure that it shares at least one cipher-suite with the server that it is trying to communicate securely with. By itself, this fact would imply that the client should simply enable all possible suites in order to increase the chances of overlap. However, this is not necessarily wise since some cipher-suites, esp. those which adhered to the (now defunct) US export restriction,s are relatively easy to break, whereas some others are trusted as currently being virtually unbreakable.

This library supports many cipher-suites (SSLFTPCipherSuite) so it should be possible to find a suitable cipher-suite in most cases. Cipher-suites are configured on the client using the CipherSuites property.

SOCKS: SOCKS may be used for FTPing through firewalls. For this to be possible a SOCKS proxy must be available, and a user account must be set up on that proxy. SSLFTPClient supports all the popular versions of SOCKS - 4, 4A, and 5.

The SOCKS features are controlled entirely through the SocksContext property. If it is null (the default) then SOCKS is not used. To use SOCKS, the property must be set to an instance of Socks4Context or Socks5Context. For example, for SOCKS4:

myFTPClient.SocksContext = new Socks4Context("192.168.0.2", 1080, "marvin23"); and for SOCKS5: Socks5Context socksContext = new Socks5Context("192.168.0.2", 1080); socksContext.AuthMethods.Add(new Socks5NoAuthMethod()); socksContext.AuthMethods.Add(new Socks5UserNamePasswordAuthMethod("marvin23", "m31erk")); myFTPClient.SocksContext = socksContext;

Constructors

SSLFTPClient Default constructor.

Properties

ActiveIPAddress Force the PORT command to send a fixed IP address, used only for certain firewalls
(Inherited from FTPClient)
ActivePortRange Port range for active mode, used only if it is necessary to limit the ports to a narrow range specified in a firewall
(Inherited from FTPClient)
AllowCustomDHGroups Controls/indicates whether custom diffie-helman groups are permitted
AutoPassiveIPSubstitution Use AutoPassiveIPSubstitution to ensure that data-socket connections are made to the same IP address that the control socket is connected to.
(Inherited from FTPClient)
CipherSuites Get/sets the cipher-suites permissible during establishment of a secure connection.
ClientCertificate The certificate to be presented to the server.
CloseStreamsAfterTransfer If true then streams are closed after a transfer has completed.
(Inherited from FTPClient)
Connected Is the client currently connected?
(Inherited from FTPClient)
ConnectMode The connection-mode (passive or active) of data-channels.
(Inherited from FTPClient)
ControlEncoding The encoding to use when dealing with file and directory paths.
(Inherited from FTPClient)
ControlPort The port on the server to which to connect the control-channel.
(Inherited from FTPClient)
CountBeforeSleep Number of transfers before going to sleep
(Inherited from ExFTPClient)
DataEncoding The encoding to use for data when transferring in ASCII mode.
(Inherited from FTPClient)
DeleteOnFailure Controls whether or not a file is deleted when a failure occurs.
(Inherited from FTPClient)
DetectTransferMode If set to true, the transfer mode in operations involving multiple files is automatically changed between ASCII and binary as appropriate.
(Inherited from ExFTPClient)
DirectoryEmptyMessages Holds fragments of server messages that indicate a directory is empty
(Inherited from FTPClient)
FileNotFoundMessages Holds fragments of server messages that indicate a file was not found
(Inherited from FTPClient)
ForceConnectModeExtensions Force the use of EPRT and EPSV extensions even for IPv4
(Inherited from ExFTPClient)
FTPFileFactory Override the chosen file factory with a user created one - meaning that a specific parser has been selected.
(Inherited from FTPClient)
IsConnected Indicates whether the client is currently connected with the server.
(Inherited from FTPClient)
IsControlChannelSecure Indicates whether the control channel is currently secure.
IsImplicitFTPS Controls/indicates whether this client is performing explicit or implicit FTPS.
IsResuming Returns true if the next transfer is to be resumed (i.e. Resume has been called).
(Inherited from FTPClient)
LastBytesTransferred The number of bytes transferred in the last transfer operation.
(Inherited from FTPClient)
LastFileTransferred The remote name/path of the last file transferred.
(Inherited from FTPClient)
LastValidReplyThe latest valid reply from the server.
(Inherited from FTPClient)
LicenseKey The license key string.
(Inherited from ExFTPClient)
LicenseOwner The license owner string.
(Inherited from ExFTPClient)
LogTagLog tag
(Inherited from FTPClient)
MaxSSLVersion Get/sets the maximum SSL/TLS version to use. TLS is the successor to SSL and should be used unless the server does not support it - SSL 3.0 has various vulnerabilities such as the POODLE exploit. SSLFTPSSLVersion.DETECT no longer will interoperate with SSL 3.0.
MaxTransferRate The maximum transfer rate in bytes per sec
(Inherited from ExFTPClient)
MinSSLVersion Get/sets the minimum SSL/TLS version to use. TLS is the successor to SSL and should be used unless the server does not support it - SSL 3.0 has various vulnerabilities such as the POODLE exploit. SSLFTPSSLVersion.DETECT no longer will interoperate with SSL 3.0.
ParsingCultureThe culture for parsing file listings.
(Inherited from FTPClient)
ProxySettings Settings for using proxies.
(Inherited from ExFTPClient)
RemoteHost Get/set the name of the remote host.
(Overrides FTPClientRemoteHost)
RootCertificates Returns an array containing all root certificates.
ServerCertificate The certificate presented by the server.
ServerCommonName The name to be used when performing a name-check during the validation of the server certificate.
ServerCompatibility Controls various server security compatibility features.
ServerValidation Controls the way in which server certificates are validated.
ServerValidationCertificate 
ServerWakeupInterval The interval in seconds that the server is sent a wakeup message during large transfers.
(Inherited from FTPClient)
SessionResumptionRequiresExtendedMasterSecret Controls/indicates whether this client requires using the extended master secret for TLS session resumption in TLS versions up to 1.2. Currently session resumption is not supported in TLS 1.3.
ShowHiddenFiles Include hidden files in operations that involve listing of directories, and if supported by the server.
(Inherited from FTPClient)
SleepEnabled Enabling or not of sleeping after a certain number of transfers
(Inherited from ExFTPClient)
SleepTime Number of seconds spent asleep
(Inherited from ExFTPClient)
SSLVersion Get/sets the minimum SSL/TLS version to use. TLS is the successor to SSL and should be used unless the server does not support it - SSL 3.0 has various vulnerabilities such as the POODLE exploit. SSLFTPSSLVersion.DETECT no longer will interoperate with SSL 3.0.
Obsolete
StrictReturnCodesControls whether or not checking of return codes is strict.
(Inherited from FTPClient)
SynchronizePassiveConnections For cases where your FTP server does not properly manage PASV connections, it may be necessary to synchronize the creation of passive data sockets. It has been reported that some FTP servers (such as those at Akamai) appear to get confused when multiple FTP clients from the same IP address attempt to connect at the same time. The default value for SynchronizePassiveConnections is false.
(Inherited from FTPClient)
TCPBufferSize TCP read/write buffer size on the underlying sockets.
(Inherited from FTPClient)
TimeDifference Time difference between server and client (relative to client).
(Inherited from FTPClient)
TimeIncludesSeconds Indicates whether seconds were included in the most recent directoy listing.
(Inherited from FTPClient)
Timeout TCP timeout on the underlying sockets, in milliseconds.
(Inherited from FTPClient)
TransferBufferSize The size of the buffers (in bytes) used in writing to and reading from the data-sockets.
(Inherited from FTPClient)
TransferCompleteMessages Holds fragments of server messages that indicate a transfer completed.
(Inherited from FTPClient)
TransferNotifyInterval The number of bytes transferred between each notification of the BytesTransferred event.
(Inherited from FTPClient)
TransferNotifyListings By default the BytesTransferred event is not triggered during directory listings - this property can be used to enable this behaviour.
(Inherited from FTPClient)
TransferTypeThe current file transfer type (BINARY or ASCII).
(Inherited from FTPClient)
UseClientHelloExtension Controls/indicates whether this client is using the SSL client hello signature extension for when TLS 1.2 is one of the protocol version options
UseSessionResumption Controls/indicates whether this client is using SSL/TLS session resumption. TLS session resumption is not currently supported in TLS 1.3.
WelcomeMessage Server welcome message.
(Inherited from FTPClient)

Methods

AbortAbort the current action.
(Inherited from FTPClient)
Account Supply account information string to the server.
(Inherited from FTPClient)
Auth (Implicit FTPS only) Instructs the server that data-channels should be secure.
Auth(SSLFTPSSLVersion) Switches the control-channel (the connection which carries commands) to secure mode.
Auth(SSLFTPSSLVersion, Boolean) Switches the control-channel (the connection which carries commands) to secure mode.
Auth(SSLFTPSSLVersion, SSLFTPSSLVersion, Boolean) Switches the control-channel (the connection which carries commands) to secure mode.
CancelResume Cancel the resume. Use this method if something goes wrong and the server is left in an inconsistent state
(Inherited from FTPClient)
CancelTransferCancels the current transfer.
(Inherited from FTPClient)
CdUpChange the remote working directory to the parent directory.
(Inherited from FTPClient)
ChDirChange the remote working directory to that supplied.
(Inherited from FTPClient)
ClearControlChannel Clears the control channel, setting it back to plain text.
CloseDataSocket(Stream)
(Inherited from FTPClient)
CloseDataSocket(StreamReader)
(Inherited from FTPClient)
CloseDataSocket(StreamWriter)
(Inherited from FTPClient)
Connect Connects to the FTP server.
(Overrides ExFTPClientConnect)
DebugResponsesSwitch debug of responses on or off
(Inherited from FTPClient)
DeleteDelete the specified remote file.
(Inherited from FTPClient)
Dir List current directory's contents as an array of strings of filenames.
(Inherited from FTPClient)
Dir(String) List a directory's contents as an array of strings of filenames.
(Inherited from FTPClient)
Dir(String, Boolean) List a directory's contents as an array of strings.
(Inherited from FTPClient)
DirDetails List the current directory's contents as an array of FTPFile objects.
(Inherited from FTPClient)
DirDetails(String) List a directory's contents as an array of FTPFile objects.
(Inherited from FTPClient)
DirDetails(String, Boolean) Returns the given directory's contents and optionally that of its subdirectories as an array of FTPFile objects.
(Inherited from ExFTPClient)
DirDetails(String, FTPFileCallback) List a directory's contents as an array of FTPFile objects.
(Inherited from FTPClient)
EnableModeZCompression Set MODE Z so that all subsequent transfers are compressed. Not supported by some servers
(Inherited from ExFTPClient)
EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Exists Checks for the existence of a file on the server.
(Inherited from FTPClient)
FeaturesGet the server supplied features.
(Inherited from FTPClient)
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
Get(String)Get data from the FTP server.
(Inherited from FTPClient)
Get(Stream, String) Get data from the FTP server, using the currently set transfer mode.
(Inherited from FTPClient)
Get(String, String) Get data from the FTP server using the currently set transfer mode.
(Inherited from FTPClient)
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetInputStream
(Inherited from ExFTPClient)
GetLocalCRC Get the CRC-32 checksum for the named local file
(Inherited from ExFTPClient)
GetOutputStream
(Inherited from ExFTPClient)
GetRemoteCRC Get the CRC-32 checksum for the named remote file
(Inherited from ExFTPClient)
GetSystemGet the type of the OS at the server.
(Inherited from FTPClient)
GetTypeGets the Type of the current instance.
(Inherited from Object)
Help Get the help text for the specified command
(Inherited from FTPClient)
KillControlChannel
(Inherited from FTPClient)
LoginLogin into an account on the FTP server using the user-name and password provided.
(Inherited from FTPClient)
MemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
MkDirCreate the specified remote working directory.
(Inherited from FTPClient)
ModTimeGet modification time for a remote file.
(Inherited from FTPClient)
MultipleDelete(FileFilter) Delete multiple files in the current remote directory
(Inherited from ExFTPClient)
MultipleDelete(String) Delete multiple files in the current remote directory
(Inherited from ExFTPClient)
MultipleDelete(String, FileFilter, Boolean) Delete multiple files in the current remote directory and its subdirectories.
(Inherited from ExFTPClient)
MultipleDelete(String, String, Boolean) Delete multiple files in the current remote directory and its subdirectories.
(Inherited from ExFTPClient)
MultipleDeleteDirectories Remove a remote directory, and all its files and its subdirectories
(Inherited from ExFTPClient)
MultipleGet(String, FileFilter) Get multiple files into the specified local directory from the current remote directory
(Inherited from ExFTPClient)
MultipleGet(String, String) Get multiple files into the specified local directory from the current remote directory
(Inherited from ExFTPClient)
MultipleGet(String, String, FileFilter, Boolean) Get multiple files from the specified remote directory into the specified local directory
(Inherited from ExFTPClient)
MultipleGet(String, String, String, Boolean) Get multiple files from the specified remote directory into the specified local directory
(Inherited from ExFTPClient)
MultiplePut(String, FileFilter) Put multiple files from the specified local directory into the current remote directory
(Inherited from ExFTPClient)
MultiplePut(String, String) Put multiple files from the specified local directory into the current remote directory
(Inherited from ExFTPClient)
MultiplePut(String, String, FileFilter, Boolean) Put multiple files from the specified local directory into the specified remote directory
(Inherited from ExFTPClient)
MultiplePut(String, String, String, Boolean) Put multiple files from the specified local directory into the specified remote directory
(Inherited from ExFTPClient)
NoOperation Send a "no operation" message that does nothing, which can be called periodically to prevent the connection timing out.
(Inherited from FTPClient)
Password Supplies the password for a previously supplied user-name to log into the FTP server. Must be preceeded by the User(String) method
(Inherited from FTPClient)
Pbsz Defines the buffer-size to be used on data-connections.
Prot Defines the security-level of subsequent data-transfers.
Put(Byte, String) Put data onto the FTP server in the current directory.
(Inherited from FTPClient)
Put(Stream, String) Put a stream of data onto the FTP server in the current directory.
(Inherited from FTPClient)
Put(String, String) Put a local file onto the FTP server in the current directory.
(Inherited from FTPClient)
Put(Byte, String, Boolean) Put data onto the FTP server in the current directory. Allows appending if current file exists.
(Inherited from FTPClient)
Put(Stream, String, Boolean) Put a stream of data onto the FTP server in the current directory. Allows appending if current file exists
(Inherited from FTPClient)
Put(String, String, Boolean) Put a local file onto the FTP server in the current directory. Allows appending if current file exists.
(Inherited from FTPClient)
PwdGet the current remote working directory.
(Inherited from FTPClient)
QuitQuit the FTP session by sending a QUIT command before closing the socket.
(Overrides FTPClientQuit)
QuitImmediately Quit the FTP session immediately by closing the control socket without sending the QUIT command.
(Inherited from FTPClient)
QuoteIssue arbitrary ftp commands to the FTP server.
(Inherited from FTPClient)
RenameRename a file or directory.
(Inherited from FTPClient)
RestartSet the REST marker so that the next transfer doesn't start at the beginning of the remote file
(Inherited from FTPClient)
ResumeMake the next file transfer (put or get) resume.
(Inherited from FTPClient)
ResumeDownloadMake the next download resume at a specific point.
(Inherited from FTPClient)
RmDirDelete the specified remote working directory.
(Inherited from FTPClient)
SetModTimeSets the modification time of a remote file.
(Inherited from FTPClient)
SiteRun a site-specific command on the server.
(Inherited from FTPClient)
Size Get the size of a remote file.
(Inherited from FTPClient)
TestConnection Tests the connection
(Inherited from FTPClient)
ToStringReturns a string that represents the current object.
(Inherited from Object)
Unlock Unlock the software for use. This method should be used when a configuration file isn't available
(Inherited from ExFTPClient)
User Supply the user-name to log into an account on the FTP server. Must be followed by the Password(String) method. Note that Connect must be called first.
(Inherited from FTPClient)
ValidateTransferValidate that the Put() or get() was successful.
(Inherited from FTPClient)
ValidateTransferOnError Validate a transfer when an error has occurred on the data channel. Set a very short transfer in case things have hung. Set it back at the end.
(Inherited from FTPClient)

Events

BytesTransferred Event triggered every time TransferNotifyInterval bytes transferred.
(Inherited from FTPClient)
CommandError Occurs when there is an error while a command was being sent or a reply was being received.
(Inherited from FTPClient)
CommandSent Triggered every time a command is sent to the server.
(Inherited from FTPClient)
ReplyReceived Triggered every time a reply is received from the server.
(Inherited from FTPClient)
TransferCompleteEx Notifies of the completion of a transfer, and supplies more details than TransferComplete
(Inherited from FTPClient)
TransferStartedEx Notifies of the start of a transfer, and supplies more details than TransferStarted
(Inherited from FTPClient)
ValidatingServer Notifies that the server must be validated.

Fields

key License key
(Inherited from ExFTPClient)
logTag Logging tag
(Inherited from FTPClient)
noOperationInterval Interval for NOOP calls during large transfers in seconds
(Inherited from FTPClient)
owner License owner
(Inherited from ExFTPClient)
socks SOCKS settings
(Inherited from ExFTPClient)
throttler Threshold for throttling
(Inherited from FTPClient)

See Also