edtFTPnet/PRO - Secure FTP component for .NET | Free Trial | Pricing
Click or drag to resize

SSLFTPClient Class

Provides low-level access to FTP/FTPS functionality.
Inheritance Hierarchy

Namespace:  EnterpriseDT.Net.Ftp.Ssl
Assembly:  edtFTPnetPRO (in edtFTPnetPRO.dll) Version: 12.3.0.0
Syntax
public class SSLFTPClient : ExFTPClient

The SSLFTPClient type exposes the following members.

Constructors
  NameDescription
Public methodSSLFTPClient
Default constructor.
Top
Properties
  NameDescription
Public propertyActiveIPAddress
Force the PORT command to send a fixed IP address, used only for certain firewalls
(Inherited from FTPClient.)
Public propertyActivePortRange
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.)
Public propertyAllowCustomDHGroups
Controls/indicates whether custom diffie-helman groups are permitted
Public propertyAutoPassiveIPSubstitution
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.)
Public propertyCipherSuites
Get/sets the cipher-suites permissible during establishment of a secure connection.
Public propertyClientCertificate
The certificate to be presented to the server.
Public propertyCloseStreamsAfterTransfer
If true then streams are closed after a transfer has completed.
(Inherited from FTPClient.)
Public propertyConnected
Is the client currently connected?
(Inherited from FTPClient.)
Public propertyConnectMode
The connection-mode (passive or active) of data-channels.
(Inherited from FTPClient.)
Public propertyControlEncoding
The encoding to use when dealing with file and directory paths.
(Inherited from FTPClient.)
Public propertyControlPort
The port on the server to which to connect the control-channel.
(Inherited from FTPClient.)
Public propertyCountBeforeSleep
Number of transfers before going to sleep
(Inherited from ExFTPClient.)
Public propertyDataEncoding
The encoding to use for data when transferring in ASCII mode.
(Inherited from FTPClient.)
Public propertyDeleteOnFailure
Controls whether or not a file is deleted when a failure occurs.
(Inherited from FTPClient.)
Public propertyDetectTransferMode
If set to true, the transfer mode in operations involving multiple files is automatically changed between ASCII and binary as appropriate.
(Inherited from ExFTPClient.)
Public propertyDirectoryEmptyMessages
Holds fragments of server messages that indicate a directory is empty
(Inherited from FTPClient.)
Public propertyFileNotFoundMessages
Holds fragments of server messages that indicate a file was not found
(Inherited from FTPClient.)
Public propertyForceConnectModeExtensions
Force the use of EPRT and EPSV extensions even for IPv4
(Inherited from ExFTPClient.)
Public propertyFTPFileFactory
Override the chosen file factory with a user created one - meaning that a specific parser has been selected.
(Inherited from FTPClient.)
Public propertyIsConnected
Indicates whether the client is currently connected with the server.
(Inherited from FTPClient.)
Public propertyIsControlChannelSecure
Indicates whether the control channel is currently secure.
Public propertyIsImplicitFTPS
Controls/indicates whether this client is performing explicit or implicit FTPS.
Public propertyIsResuming
Returns true if the next transfer is to be resumed (i.e. Resume has been called).
(Inherited from FTPClient.)
Public propertyLastBytesTransferred
The number of bytes transferred in the last transfer operation.
(Inherited from FTPClient.)
Public propertyLastFileTransferred
The remote name/path of the last file transferred.
(Inherited from FTPClient.)
Public propertyLastValidReply
The latest valid reply from the server.
(Inherited from FTPClient.)
Public propertyLicenseKey
The license key string.
(Inherited from ExFTPClient.)
Public propertyLicenseOwner
The license owner string.
(Inherited from ExFTPClient.)
Public propertyLogTag
Log tag
(Inherited from FTPClient.)
Public propertyMaxSSLVersion
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.
Public propertyMaxTransferRate
The maximum transfer rate in bytes per sec
(Inherited from ExFTPClient.)
Public propertyMinSSLVersion
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.
Public propertyParsingCulture
The culture for parsing file listings.
(Inherited from FTPClient.)
Public propertyProxySettings
Settings for using proxies.
(Inherited from ExFTPClient.)
Public propertyRemoteHost
Get/set the name of the remote host.
(Overrides FTPClientRemoteHost.)
Public propertyRootCertificates
Returns an array containing all root certificates.
Public propertyServerCertificate
The certificate presented by the server.
Public propertyServerCommonName
The name to be used when performing a name-check during the validation of the server certificate.
Public propertyServerCompatibility
Controls various server security compatibility features.
Public propertyServerValidation
Controls the way in which server certificates are validated.
Public propertyServerValidationCertificate
Public propertyServerWakeupInterval
The interval in seconds that the server is sent a wakeup message during large transfers.
(Inherited from FTPClient.)
Public propertySessionResumptionRequiresExtendedMasterSecret
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.
Public propertyShowHiddenFiles
Include hidden files in operations that involve listing of directories, and if supported by the server.
(Inherited from FTPClient.)
Public propertySleepEnabled
Enabling or not of sleeping after a certain number of transfers
(Inherited from ExFTPClient.)
Public propertySleepTime
Number of seconds spent asleep
(Inherited from ExFTPClient.)
Public propertySSLVersion Obsolete.
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.
Public propertyStrictReturnCodes
Controls whether or not checking of return codes is strict.
(Inherited from FTPClient.)
Public propertySynchronizePassiveConnections
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.)
Public propertyTCPBufferSize
TCP read/write buffer size on the underlying sockets.
(Inherited from FTPClient.)
Public propertyTimeDifference
Time difference between server and client (relative to client).
(Inherited from FTPClient.)
Public propertyTimeIncludesSeconds
Indicates whether seconds were included in the most recent directoy listing.
(Inherited from FTPClient.)
Public propertyTimeout
TCP timeout on the underlying sockets, in milliseconds.
(Inherited from FTPClient.)
Public propertyTransferBufferSize
The size of the buffers (in bytes) used in writing to and reading from the data-sockets.
(Inherited from FTPClient.)
Public propertyTransferCompleteMessages
Holds fragments of server messages that indicate a transfer completed.
(Inherited from FTPClient.)
Public propertyTransferNotifyInterval
The number of bytes transferred between each notification of the BytesTransferred event.
(Inherited from FTPClient.)
Public propertyTransferNotifyListings
By default the BytesTransferred event is not triggered during directory listings - this property can be used to enable this behaviour.
(Inherited from FTPClient.)
Public propertyTransferType
The current file transfer type (BINARY or ASCII).
(Inherited from FTPClient.)
Public propertyUseClientHelloExtension
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
Public propertyUseSessionResumption
Controls/indicates whether this client is using SSL/TLS session resumption. TLS session resumption is not currently supported in TLS 1.3.
Public propertyWelcomeMessage
Server welcome message.
(Inherited from FTPClient.)
Top
Methods
  NameDescription
Protected methodAbort
Abort the current action.
(Inherited from FTPClient.)
Public methodAccount
Supply account information string to the server.
(Inherited from FTPClient.)
Public methodAuth
(Implicit FTPS only) Instructs the server that data-channels should be secure.
Public methodAuth(SSLFTPSSLVersion)
Switches the control-channel (the connection which carries commands) to secure mode.
Public methodAuth(SSLFTPSSLVersion, Boolean)
Switches the control-channel (the connection which carries commands) to secure mode.
Public methodAuth(SSLFTPSSLVersion, SSLFTPSSLVersion, Boolean)
Switches the control-channel (the connection which carries commands) to secure mode.
Public methodCancelResume
Cancel the resume. Use this method if something goes wrong and the server is left in an inconsistent state
(Inherited from FTPClient.)
Public methodCancelTransfer
Cancels the current transfer.
(Inherited from FTPClient.)
Public methodCdUp
Change the remote working directory to the parent directory.
(Inherited from FTPClient.)
Public methodChDir
Change the remote working directory to that supplied.
(Inherited from FTPClient.)
Public methodClearControlChannel
Clears the control channel, setting it back to plain text.
Protected methodCloseDataSocket(Stream) (Inherited from FTPClient.)
Protected methodCloseDataSocket(StreamReader) (Inherited from FTPClient.)
Protected methodCloseDataSocket(StreamWriter) (Inherited from FTPClient.)
Public methodConnect
Connects to the FTP server.
(Overrides ExFTPClientConnect.)
Public methodDebugResponses
Switch debug of responses on or off
(Inherited from FTPClient.)
Public methodDelete
Delete the specified remote file.
(Inherited from FTPClient.)
Public methodDir
List current directory's contents as an array of strings of filenames.
(Inherited from FTPClient.)
Public methodDir(String)
List a directory's contents as an array of strings of filenames.
(Inherited from FTPClient.)
Public methodDir(String, Boolean)
List a directory's contents as an array of strings.
(Inherited from FTPClient.)
Public methodDirDetails
List the current directory's contents as an array of FTPFile objects.
(Inherited from FTPClient.)
Public methodDirDetails(String)
List a directory's contents as an array of FTPFile objects.
(Inherited from FTPClient.)
Public methodDirDetails(String, Boolean)
Returns the given directory's contents and optionally that of its subdirectories as an array of FTPFile objects.
(Inherited from ExFTPClient.)
Public methodDirDetails(String, FTPFileCallback)
List a directory's contents as an array of FTPFile objects.
(Inherited from FTPClient.)
Public methodEnableModeZCompression
Set MODE Z so that all subsequent transfers are compressed. Not supported by some servers
(Inherited from ExFTPClient.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodExists
Checks for the existence of a file on the server.
(Inherited from FTPClient.)
Public methodFeatures
Get the server supplied features.
(Inherited from FTPClient.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGet(String)
Get data from the FTP server.
(Inherited from FTPClient.)
Public methodGet(Stream, String)
Get data from the FTP server, using the currently set transfer mode.
(Inherited from FTPClient.)
Public methodGet(String, String)
Get data from the FTP server using the currently set transfer mode.
(Inherited from FTPClient.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Protected methodGetInputStream (Inherited from ExFTPClient.)
Public methodGetLocalCRC
Get the CRC-32 checksum for the named local file
(Inherited from ExFTPClient.)
Protected methodGetOutputStream (Inherited from ExFTPClient.)
Public methodGetRemoteCRC
Get the CRC-32 checksum for the named remote file
(Inherited from ExFTPClient.)
Public methodGetSystem
Get the type of the OS at the server.
(Inherited from FTPClient.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodHelp
Get the help text for the specified command
(Inherited from FTPClient.)
Public methodKillControlChannel (Inherited from FTPClient.)
Public methodLogin
Login into an account on the FTP server using the user-name and password provided.
(Inherited from FTPClient.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodMkDir
Create the specified remote working directory.
(Inherited from FTPClient.)
Public methodModTime
Get modification time for a remote file.
(Inherited from FTPClient.)
Public methodMultipleDelete(FileFilter)
Delete multiple files in the current remote directory
(Inherited from ExFTPClient.)
Public methodMultipleDelete(String)
Delete multiple files in the current remote directory
(Inherited from ExFTPClient.)
Public methodMultipleDelete(String, FileFilter, Boolean)
Delete multiple files in the current remote directory and its subdirectories.
(Inherited from ExFTPClient.)
Public methodMultipleDelete(String, String, Boolean)
Delete multiple files in the current remote directory and its subdirectories.
(Inherited from ExFTPClient.)
Public methodMultipleDeleteDirectories
Remove a remote directory, and all its files and its subdirectories
(Inherited from ExFTPClient.)
Public methodMultipleGet(String, FileFilter)
Get multiple files into the specified local directory from the current remote directory
(Inherited from ExFTPClient.)
Public methodMultipleGet(String, String)
Get multiple files into the specified local directory from the current remote directory
(Inherited from ExFTPClient.)
Public methodMultipleGet(String, String, FileFilter, Boolean)
Get multiple files from the specified remote directory into the specified local directory
(Inherited from ExFTPClient.)
Public methodMultipleGet(String, String, String, Boolean)
Get multiple files from the specified remote directory into the specified local directory
(Inherited from ExFTPClient.)
Public methodMultiplePut(String, FileFilter)
Put multiple files from the specified local directory into the current remote directory
(Inherited from ExFTPClient.)
Public methodMultiplePut(String, String)
Put multiple files from the specified local directory into the current remote directory
(Inherited from ExFTPClient.)
Public methodMultiplePut(String, String, FileFilter, Boolean)
Put multiple files from the specified local directory into the specified remote directory
(Inherited from ExFTPClient.)
Public methodMultiplePut(String, String, String, Boolean)
Put multiple files from the specified local directory into the specified remote directory
(Inherited from ExFTPClient.)
Public methodNoOperation
Send a "no operation" message that does nothing, which can be called periodically to prevent the connection timing out.
(Inherited from FTPClient.)
Public methodPassword
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.)
Public methodPbsz
Defines the buffer-size to be used on data-connections.
Public methodProt
Defines the security-level of subsequent data-transfers.
Public methodPut(Byte, String)
Put data onto the FTP server in the current directory.
(Inherited from FTPClient.)
Public methodPut(Stream, String)
Put a stream of data onto the FTP server in the current directory.
(Inherited from FTPClient.)
Public methodPut(String, String)
Put a local file onto the FTP server in the current directory.
(Inherited from FTPClient.)
Public methodPut(Byte, String, Boolean)
Put data onto the FTP server in the current directory. Allows appending if current file exists.
(Inherited from FTPClient.)
Public methodPut(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.)
Public methodPut(String, String, Boolean)
Put a local file onto the FTP server in the current directory. Allows appending if current file exists.
(Inherited from FTPClient.)
Public methodPwd
Get the current remote working directory.
(Inherited from FTPClient.)
Public methodQuit
Quit the FTP session by sending a QUIT command before closing the socket.
(Overrides FTPClientQuit.)
Public methodQuitImmediately
Quit the FTP session immediately by closing the control socket without sending the QUIT command.
(Inherited from FTPClient.)
Public methodQuote
Issue arbitrary ftp commands to the FTP server.
(Inherited from FTPClient.)
Public methodRename
Rename a file or directory.
(Inherited from FTPClient.)
Public methodRestart
Set the REST marker so that the next transfer doesn't start at the beginning of the remote file
(Inherited from FTPClient.)
Public methodResume
Make the next file transfer (put or get) resume.
(Inherited from FTPClient.)
Public methodResumeDownload
Make the next download resume at a specific point.
(Inherited from FTPClient.)
Public methodRmDir
Delete the specified remote working directory.
(Inherited from FTPClient.)
Public methodSetModTime
Sets the modification time of a remote file.
(Inherited from FTPClient.)
Public methodSite
Run a site-specific command on the server.
(Inherited from FTPClient.)
Public methodSize
Get the size of a remote file.
(Inherited from FTPClient.)
Public methodTestConnection
Tests the connection
(Inherited from FTPClient.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodUnlock
Unlock the software for use. This method should be used when a configuration file isn't available
(Inherited from ExFTPClient.)
Public methodUser
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.)
Public methodValidateTransfer
Validate that the Put() or get() was successful.
(Inherited from FTPClient.)
Protected methodValidateTransferOnError
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.)
Top
Events
  NameDescription
Public eventBytesTransferred
Event triggered every time TransferNotifyInterval bytes transferred.
(Inherited from FTPClient.)
Public eventCommandError
Occurs when there is an error while a command was being sent or a reply was being received.
(Inherited from FTPClient.)
Public eventCommandSent
Triggered every time a command is sent to the server.
(Inherited from FTPClient.)
Public eventReplyReceived
Triggered every time a reply is received from the server.
(Inherited from FTPClient.)
Public eventTransferCompleteEx
Notifies of the completion of a transfer, and supplies more details than TransferComplete
(Inherited from FTPClient.)
Public eventTransferStartedEx
Notifies of the start of a transfer, and supplies more details than TransferStarted
(Inherited from FTPClient.)
Public eventValidatingServer
Notifies that the server must be validated.
Top
Fields
  NameDescription
Protected fieldkey
License key
(Inherited from ExFTPClient.)
Protected fieldlogTag
Logging tag
(Inherited from FTPClient.)
Protected fieldnoOperationInterval
Interval for NOOP calls during large transfers in seconds
(Inherited from FTPClient.)
Protected fieldowner
License owner
(Inherited from ExFTPClient.)
Protected fieldsocks
SOCKS settings
(Inherited from ExFTPClient.)
Protected fieldthrottler
Threshold for throttling
(Inherited from FTPClient.)
Top
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.

Examples
This example shows a simple explicit FTPS session.
// 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.

Examples
This example shows a simple implicit FTPS session:
// 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;
See Also