FTPServer Class

Properties   Methods   Events   Config Settings   Errors  

The FTPServer Class is used to create an FTP server.

Syntax

ipworkscdata.FTPServer

Remarks

The FTPServer Class provides a simple way to create an FTP server. Any FTP client will be able to connect and transfer files to and from the server.

The FTP Class supports both plaintext and Secure Sockets Layer/Transport Layer Security (SSL/TLS) connections. When connecting over Secure Sockets Layer/Transport Layer Security (SSL/TLS) the SSLServerAuthentication event allows you to check the server identity and other security attributes. The SSLStatus event provides information about the SSL handshake. Additional SSL-related settings are also supported through the Config method.

The FTP Class implements a standard FTP server as specified in RFC 959 and RFC 1579 with the added option of SSL security (RFC 2228) in both the protocol and data channels.

Required Properties

The first step in using the class is specifying the LocalPort and calling AddUser to add credentials that clients can use to log into the server. A DefaultRootDir also may be set in the event that not all Users have their own home directories. To use the class with SSL, use SSLEnabled and SSLCert. Finally, set Listening to True. Clients will now be able to connect and browse the directory specified with without further setup.

The PITrail event traces the interaction between the client and the server (the FTP Protocol Interface connection).

Handling Events

Event handlers are the primary method of customizing the class's functionality. When a client attempts to connect, open a file, or authenticate to the server, the corresponding FTPServer event will fire to allow for custom handling of the client's request.

This functionality is especially useful for virtual directory functionality: the client may browse to a directory that does not physically exist in the location requested by the client. The server may use event handling to process directory listing, file and directory manipulation, and transfers for such "virtual" files and directory. By sending the applicable responses for such requests back to the client, it appears to the client that the virtual files and directories exist normally, when in reality, they may exist in another location or not at all.

The following events are fired both before and after the requested operation is executed:

Each of these events has a BeforeExec event parameter that is True when the event is fired before execution of the operation, and False after execution of the operation. Handling the event before execution provides an opportunity to use custom logic to determine whether the operation should be denied, diverted, or otherwise modified. A corresponding custom response also may be sent to the client (see the event's documentation for details). Handling the event after execution provides an opportunity to report success or any errors related to the operation to the client.

Supported Commands

The following commands are supported by the class. Additional commands may be implemented by handling the Command event.

ABOR ADAT ALLO APPE AUTH
CDUP CLNT CWD DELE EPRT
EPSV FEAT HASH HELP LIST
MDTM MFMT MKD MLSD MLST
MODE NLST NOOP OPTS PASS
PASV PBSZ PORT PROT PWD
QUIT REST RETR RMD RNFR
RNTO SITE SIZE STOR STOU
SYST TYPE USER

NOTE: Server components are designed to process events as they occur. To ensure that events are processed in a timely manner, DoEvents should be called in a loop after the server is started.

Property List


The following is the full list of the properties of the class with short descriptions. Click on the links for further details.

Connections This is a collection of currently connected clients.
DefaultIdleTimeout This is the default idle timeout in seconds.
DefaultRootDir This is the default local root directory for connecting clients.
DefaultTimeout This property includes an initial timeout value to be used by incoming connections.
Listening This property indicates whether the class is listening for incoming connections on LocalPort.
LocalHost The name of the local host or user-assigned IP interface through which connections are initiated or accepted.
LocalPort The TCP port in the local host where the class listens.
SSLAuthenticateClients If set to True, the server asks the client(s) for a certificate.
SSLCert The certificate to be used during Secure Sockets Layer (SSL) negotiation.
SSLEnabled This property indicates whether Transport Layer Security/Secure Sockets Layer (TLS/SSL) is enabled.
SSLStartMode This property determines how the class starts the Secure Sockets Layer (SSL) negotiation.
Users This is the collection of users authorized to connect to the server.

Method List


The following is the full list of the methods of the class with short descriptions. Click on the links for further details.

AddDirEntry This methods adds an entry to the list sent to the client during a directory list request.
AddUser This method adds credentials for a new user who is approved to connect to the server.
Config Sets or retrieves a configuration setting.
Disconnect This method disconnects the specified client.
DoEvents This method processes events from the internal message queue.
Interrupt This method interrupts a synchronous send to the remote host.
RemoveUser This method removes a user from the list of those authorized to connect to the server.
Reset This method will reset the class.
SetInputStream This method sets a file stream to be used when a client downloads a file.
SetOutputStream This method sets a file stream to be used when a client uploads a file.
Shutdown This method shuts down the server.
StartListening This method starts listening for incoming connections.
StopListening This method stops listening for new connections.

Event List


The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.

Command This event fires when an unrecognized command is received from a client.
Connected This event fires immediately after a connection completes (or fails).
ConnectionRequest This event fires when a client makes a connection request.
DirChange This event fires during processing of a directory change request.
DirCreate This event fires during processing of a directory creation request.
DirList This event fires during processing of a directory list request.
DirRemove This event fires during processing of a directory remove request.
Disconnected This event fires when a client is disconnected.
EndTransfer This event fires when a transfer of data ends.
Error This includes information about errors during data delivery.
FileDelete This event fires during processing of a file delete request.
FileDownload This event fires during processing of a file download request.
FileGetModifiedTime This event fires during processing of an MDTM command.
FileGetSize This event fires during processing of a SIZE command.
FileRename This event fires during processing of a file rename request.
FileUpload This event fires during processing of a file upload request.
Log This event fires once for each log message.
PITrail This event traces the commands sent to the server, and the respective replies.
SSLClientAuthentication This event fires when the client presents its credentials to the server.
SSLConnectionRequest This event fires when an SSL connection is requested.
SSLStatus This event shows the progress of the secure connection.
StartTransfer This event fires when a transfer of data begins.
Transfer This event fires when bytes are transferred.
UserAuthentication This event fires when a client provides login credentials to the server.

Config Settings


The following is a list of config settings for the class with short descriptions. Click on the links for further details.

AllowActiveMode Whether to allow clients to connect in active mode.
AllowCompression Whether to allow MODE Z compression.
ConnectionBacklog The maximum number of pending connections maintained by the TCP/IP subsystem.
DefaultConnectionTimeout The inactivity timeout applied to SSL and DI connections.
DefaultDIInBufferSize The size in bytes of the incoming queue of the socket.
DefaultDIOutBufferSize The size in bytes of the outgoing queue of the socket.
IncludeFiletimeAge The age in days after which hours and minutes are not included in the timestamp in directory listings.
KeepAlive When True, KEEPALIVE packets are enabled (for long connections).
Linger When set to True, connections are terminated gracefully.
PassiveModeAddress Public IP address to be communicated to the client for Passive mode use.
PassiveModePortRange Range of ports to use in Passive mode connections.
WelcomeMessage The welcome message displayed to connecting clients.
AllowedClients A comma-separated list of host names or IP addresses that can access the class.
BindExclusively Whether or not the class considers a local port reserved for exclusive use.
BlockedClients A comma-separated list of host names or IP addresses that cannot access the class.
CloseStreamAfterTransfer If true, the class will close the upload or download stream after the transfer.
DefaultConnectionTimeout The inactivity timeout applied to the SSL handshake.
InBufferSize The size in bytes of the incoming queue of the socket.
KeepAliveInterval The retry interval, in milliseconds, to be used when a TCP keep-alive packet is sent and no response is received.
KeepAliveTime The inactivity time in milliseconds before a TCP keep-alive packet is sent.
MaxConnections The maximum number of connections available.
OutBufferSize The size in bytes of the outgoing queue of the socket.
PreferredDHGroupBits Size of the Diffie-Hellman group, in bits.
TcpNoDelay Whether or not to delay when sending packets.
UseIPv6 Whether to use IPv6.
LogSSLPackets Controls whether SSL packets are logged when using the internal security API.
ReuseSSLSession Determines if the SSL session is reused.
SSLCACerts A newline separated list of CA certificates to be included when performing an SSL handshake.
SSLCheckCRL Whether to check the Certificate Revocation List for the server certificate.
SSLCheckOCSP Whether to use OCSP to check the status of the server certificate.
SSLCipherStrength The minimum cipher strength used for bulk encryption.
SSLClientCACerts A newline separated list of CA certificates to use during SSL client certificate validation.
SSLContextProtocol The protocol used when getting an SSLContext instance.
SSLEnabledCipherSuites The cipher suite to be used in an SSL negotiation.
SSLEnabledProtocols Used to enable/disable the supported security protocols.
SSLEnableRenegotiation Whether the renegotiation_info SSL extension is supported.
SSLIncludeCertChain Whether the entire certificate chain is included in the SSLServerAuthentication event.
SSLKeyLogFile The location of a file where per-session secrets are written for debugging purposes.
SSLNegotiatedCipher Returns the negotiated cipher suite.
SSLNegotiatedCipherStrength Returns the negotiated cipher suite strength.
SSLNegotiatedCipherSuite Returns the negotiated cipher suite.
SSLNegotiatedKeyExchange Returns the negotiated key exchange algorithm.
SSLNegotiatedKeyExchangeStrength Returns the negotiated key exchange algorithm strength.
SSLNegotiatedVersion Returns the negotiated protocol version.
SSLServerCACerts A newline separated list of CA certificates to use during SSL server certificate validation.
SSLTrustManagerFactoryAlgorithm The algorithm to be used to create a TrustManager through TrustManagerFactory.
TLS12SignatureAlgorithms Defines the allowed TLS 1.2 signature algorithms when SSLProvider is set to Internal.
TLS12SupportedGroups The supported groups for ECC.
TLS13KeyShareGroups The groups for which to pregenerate key shares.
TLS13SignatureAlgorithms The allowed certificate signature algorithms.
TLS13SupportedGroups The supported groups for (EC)DHE key exchange.

Connections Property (FTPServer Class)

This is a collection of currently connected clients.

Syntax

public FTPConnectionMap getConnections();

Remarks

This is a collection of FTPConnection elements that contain information about each connected client.

This property is read-only and not available at design time.

Please refer to the FTPConnection type for a complete list of fields.

DefaultIdleTimeout Property (FTPServer Class)

This is the default idle timeout in seconds.

Syntax

public int getDefaultIdleTimeout();
public void setDefaultIdleTimeout(int defaultIdleTimeout);

Default Value

0

Remarks

This setting optionally specifies an idle timeout for all connected clients. If a connected client does not issue a command within DefaultIdleTimeout seconds, it automatically will be disconnected. The special value 0 indicates that no timeout is specified.

The default value is 0 (no timeout).

This property is not available at design time.

DefaultRootDir Property (FTPServer Class)

This is the default local root directory for connecting clients.

Syntax

public String getDefaultRootDir();
public void setDefaultRootDir(String defaultRootDir);

Default Value

""

Remarks

This property defines the local root directory for users with an empty local root directory value.

This property is not available at design time.

DefaultTimeout Property (FTPServer Class)

This property includes an initial timeout value to be used by incoming connections.

Syntax

public int getDefaultTimeout();
public void setDefaultTimeout(int defaultTimeout);

Default Value

0

Remarks

This property is used by the class to set the operational timeout value of all inbound connections once they are established.

This property defines the timeout when sending data. When SSLEnabled is False, a value of 0 means data will be sent asynchronously, and a positive value means data is sent synchronously.

When SSLEnabled is True, all data are sent synchronously regardless of the Timeout value.

Listening Property (FTPServer Class)

This property indicates whether the class is listening for incoming connections on LocalPort.

Syntax

public boolean isListening();

Default Value

False

Remarks

This property indicates whether the class is listening for connections on the port specified by the LocalPort property. Use the StartListening and StopListening methods to control whether the class is listening.

This property is read-only and not available at design time.

LocalHost Property (FTPServer Class)

The name of the local host or user-assigned IP interface through which connections are initiated or accepted.

Syntax

public String getLocalHost();
public void setLocalHost(String localHost);

Default Value

""

Remarks

This property contains the name of the local host as obtained by the gethostname() system call, or if the user has assigned an IP address, the value of that address.

In multihomed hosts (machines with more than one IP interface) setting LocalHost to the IP address of an interface will make the class initiate connections (or accept in the case of server classes) only through that interface. It is recommended to provide an IP address rather than a hostname when setting this property to ensure the desired interface is used.

If the class is connected, the LocalHost property shows the IP address of the interface through which the connection is made in internet dotted format (aaa.bbb.ccc.ddd). In most cases, this is the address of the local host, except for multihomed hosts (machines with more than one IP interface).

NOTE: LocalHost is not persistent. You must always set it in code, and never in the property window.

LocalPort Property (FTPServer Class)

The TCP port in the local host where the class listens.

Syntax

public int getLocalPort();
public void setLocalPort(int localPort);

Default Value

21

Remarks

This property must be set before the class can start listening. If its value is 0, then the TCP/IP subsystem picks a port number at random. The port number can be found by checking the value of this property after the class is listening (i.e., after successfully assigning True to the Listening property).

Because the service port is not shared among servers, two classes cannot be listening on the same port at the same time.

SSLAuthenticateClients Property (FTPServer Class)

If set to True, the server asks the client(s) for a certificate.

Syntax

public boolean isSSLAuthenticateClients();
public void setSSLAuthenticateClients(boolean SSLAuthenticateClients);

Default Value

False

Remarks

This property is used in conjunction with the SSLClientAuthentication event. Please refer to the documentation of the SSLClientAuthentication event for details.

SSLCert Property (FTPServer Class)

The certificate to be used during Secure Sockets Layer (SSL) negotiation.

Syntax

public Certificate getSSLCert();
public void setSSLCert(Certificate SSLCert);

Remarks

This property includes the digital certificate that the class will use during SSL negotiation. Set this property to a valid certificate before starting SSL negotiation. To set a certificate, you may set the Encoded field to the encoded certificate. To select a certificate, use the store and subject fields.

Please refer to the Certificate type for a complete list of fields.

SSLEnabled Property (FTPServer Class)

This property indicates whether Transport Layer Security/Secure Sockets Layer (TLS/SSL) is enabled.

Syntax

public boolean isSSLEnabled();
public void setSSLEnabled(boolean SSLEnabled);

Default Value

False

Remarks

This property specifies whether TLS/SSL is enabled in the class. When False (default), the class operates in plaintext mode. When True, TLS/SSL is enabled.

TLS/SSL may also be enabled by setting SSLStartMode. Setting SSLStartMode will automatically update this property value.

This property is not available at design time.

SSLStartMode Property (FTPServer Class)

This property determines how the class starts the Secure Sockets Layer (SSL) negotiation.

Syntax

public int getSSLStartMode();
public void setSSLStartMode(int SSLStartMode);

Enumerated values:
  public final static int sslAutomatic = 0;
  public final static int sslImplicit = 1;
  public final static int sslExplicit = 2;
  public final static int sslNone = 3;

Default Value

3

Remarks

The SSLStartMode property may have one of the following values:

0 (sslAutomatic)If the remote port is set to the standard plaintext port of the protocol (where applicable), the class will behave the same as if SSLStartMode is set to sslExplicit. In all other cases, SSL negotiation will be implicit (sslImplicit).
1 (sslImplicit)The SSL negotiation will start immediately after the connection is established.
2 (sslExplicit)The class will first connect in plaintext, and then will explicitly start SSL negotiation through a protocol command such as STARTTLS.
3 (sslNone - default)No SSL negotiation; no SSL security. All communication will be in plaintext mode.

Users Property (FTPServer Class)

This is the collection of users authorized to connect to the server.

Syntax

public FTPUserList getUsers();

Remarks

This is the collection of FTPUser elements that contains the names, passwords, home directories, and access policies for users approved to connect to the server.

This property is read-only and not available at design time.

Please refer to the FTPUser type for a complete list of fields.

AddDirEntry Method (FTPServer Class)

This methods adds an entry to the list sent to the client during a directory list request.

Syntax

public void addDirEntry(String connectionId, String name, long size, String modifiedTime, boolean isFile, int permission, String others);

Remarks

This method adds a file or directory (depending on isFile) to the directory contents list sent to the client when DirList is fired. This method can be called only during DirList. A connectionId and name must be specified regardless of which directory list commands are supported.

To support all directory list commands (MLST, NLST, MLSD, LIST), all parameters except for others (which may be an empty string) must be set to valid values. If a parameter is not applicable to a command issued by a client, its value will be ignored and will not be sent to the client.

others contains optional, less common fields and should be a key-value string in the format filetype=l;owner=ownerName;ownergroup=groupName;linkname=linkname.txt;nlink=5.

The following table outlines the available parameters, applicable commands, and their accepted values and formats. Unless otherwise noted, each parameter is required for all applicable commands.

Parameter Commands Description
connectionId MLST, NLST, MLSD, LIST The connection Id of the client for which the entry will be added.
name MLST, MLSD, LIST The name of the file or directory entry.
size MLST, MLSD, LIST The size of the file in bytes. Applicable only to files.
modifiedTime MLST, MLSD, LIST The date/time the file was modified. Must be in the format yyyyMMddHHmmss.
isFile MLST, MLSD, LIST Whether the entry represents a file or directory.
permission LIST A three-digit integer representing the permissions for the owner, group, and world in that order. Each digit will be interpreted as an octal digit containing the read, write, and execute (rwx) permissions represented by its three binary digits in that order. For example, a digit value 0 is no permissions, 4 is read-only, and 7 is full rwx permissions. A three-digit value of 740 would indicate full owner permissions, read-only owner group permissions, and no permissions for all others.
filetype LIST Optional; within others. A single character specifying the type of entry represented. Possible values are - (ordinary file), d (directory), l (link), s (local socket), b block special file, c (character special file), or p (FIFO special file). If unspecified, this value will be set automatically based on the values of isFile and linkname. If linkname is set, the value will be l otherwise it will be - or d depending on isFile.
linkname LIST Optional; within others. The path the entry links to. Applicable only to entries with filetype link. If this value is set and filetype is not, filetype will be l automatically. The default value is "".
nlink LIST Optional; within others. Number of links to the entry. Default is 1.
owner LIST Optional; within others. The user who owns the file. The default is the username of the currently connected client.
ownergroup LIST Optional; within others. The group associated with the file. The default is the username of the currently connected client.

When the method is called, the class will use the command that triggered the DirList event to be fired to determine the parameters and format to be used in the Response. It will build an entry string that will be added to the Response parameter and sent to the client. The method can be called repeatedly to add multiple entries to the directory contents returned.

The Response parameter also may be used to send already-formatted, complete directory entries to the client. Simply append a new line and the entry string to the Response string to add a raw entry this way.

AddUser Method (FTPServer Class)

This method adds credentials for a new user who is approved to connect to the server.

Syntax

public void addUser(String name, String password, String rootDir, String homeDir, int ACL);

Remarks

Define a user name that is allowed to connect to the server, along with that user's password, home directory, and permissions. The user will be added to the Users property.

The name parameter must be a username unique to this user.

rootDir is the local root directory for the user. If an empty string is set, the DefaultRootDir will be used upon connection.

HomeDir is the directory that will be the initial working directory for the user upon login. To use the same location as the RootDir, set it to an empty string or /. Otherwise, this value must be a virtual path relative to RootDir (or DefaultRootDir if applicable). Users may navigate up from their HomeDir as long as they do not navigate above their RootDir, which they are not able to leave. An example of the meanings of the two values follows:

RootDir HomeDir Full local home path
C:/FTPServer /Users/Me C:/FTPServer/Users/Me
Setting an empty string also will be treated as a /.

The ACL parameter controls the access policy for the user and can have the following values:

  • 0x0001: ACL_DIR_CREATE
  • 0x0002: ACL_DIR_REMOVE
  • 0x0100: ACL_FILE_UPLOAD
  • 0x0200: ACL_FILE_DELETE
  • 0x0400: ACL_FILE_RENAME
  • 0xFFFF: ACL_ALL

The credentials of clients attempting to connect to the server also may be validated using the UserAuthentication event.

Config Method (FTPServer Class)

Sets or retrieves a configuration setting.

Syntax

public String config(String configurationString);

Remarks

Config is a generic method available in every class. It is used to set and retrieve configuration settings for the class.

These settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the class, access to these internal properties is provided through the Config method.

To set a configuration setting named PROPERTY, you must call Config("PROPERTY=VALUE"), where VALUE is the value of the setting expressed as a string. For boolean values, use the strings "True", "False", "0", "1", "Yes", or "No" (case does not matter).

To read (query) the value of a configuration setting, you must call Config("PROPERTY"). The value will be returned as a string.

Disconnect Method (FTPServer Class)

This method disconnects the specified client.

Syntax

public void disconnect(String connectionId);

Remarks

Calling this method will disconnect the client specified by the ConnectionId parameter.

DoEvents Method (FTPServer Class)

This method processes events from the internal message queue.

Syntax

public void doEvents();

Remarks

When DoEvents is called, the class processes any available events. If no events are available, it waits for a preset period of time, and then returns.

Interrupt Method (FTPServer Class)

This method interrupts a synchronous send to the remote host.

Syntax

public void interrupt(String connectionId);

Remarks

This property is called using the Connection Id if you wish to interrupt a connection and stop a file from uploading without disconnecting the client connected to the class. If you use SendFile to upload a file, the class will run synchronously on that Connection Id until it is completed.

RemoveUser Method (FTPServer Class)

This method removes a user from the list of those authorized to connect to the server.

Syntax

public void removeUser(String name);

Remarks

This method removes the user with the specified name from the Users list. This user will no longer be authorized to connect to the server.

Reset Method (FTPServer Class)

This method will reset the class.

Syntax

public void reset();

Remarks

This method will reset the class's properties to their default values.

SetInputStream Method (FTPServer Class)

This method sets a file stream to be used when a client downloads a file.

Syntax

public void setInputStream(String connectionId, java.io.InputStream s);

Remarks

If set, the class will use the specified stream for the download of a file.

This method can be called within the FileDownload event to set a stream for downloading a "virtual" file, which exists at a remote location other than the one requested by the client. If this method is not called during the event, an input stream will be created at the given filename within the current remote path.

For more details on the file download process, see FileDownload.

SetOutputStream Method (FTPServer Class)

This method sets a file stream to be used when a client uploads a file.

Syntax

public void setOutputStream(String connectionId, java.io.OutputStream s);

Remarks

If set, the class will use the specified stream for a file upload.

This method can be called within the FileUpload event to set a stream for uploading a file from the client machine to a location other than the one set by the client. If this method is not called during the event, an output stream will be created at the remote path set by the client.

For more details on the file upload process, see FileUpload.

Shutdown Method (FTPServer Class)

This method shuts down the server.

Syntax

public void shutdown();

Remarks

This method shuts down the server. Calling this method is equivalent to calling StopListening and then breaking every client connection by calling Disconnect.

StartListening Method (FTPServer Class)

This method starts listening for incoming connections.

Syntax

public void startListening();

Remarks

This method begins listening for incoming connections on the port specified by LocalPort. Once listening, events will fire as new clients connect and data are transferred.

To stop listening for new connections, call StopListening. To stop listening for new connections and to disconnect all existing clients, call Shutdown.

StopListening Method (FTPServer Class)

This method stops listening for new connections.

Syntax

public void stopListening();

Remarks

This method stops listening for new connections. After being called, any new connection attempts will be rejected. Calling this method does not disconnect existing connections.

To stop listening and to disconnect all existing clients, call Shutdown instead.

Command Event (FTPServer Class)

This event fires when an unrecognized command is received from a client.

Syntax

public class DefaultFTPServerEventListener implements FTPServerEventListener {
  ...
  public void command(FTPServerCommandEvent e) {}
  ...
}

public class FTPServerCommandEvent {
  public String connectionId;
  public String command;
  public String parameters;
  public String response; //read-write
}

Remarks

This event fires when a command other than those listed below is sent to the server. The server may use its own logic to process such custom commands and may set Response to the desired value.

The ConnectionId is the Id of the connected client that caused the event to fire.

Command is the command sent by the client. Any of the following commands will not fire this event and instead will be processed by the class (custom processing must be done in the respective command-specific events).

ABOR ADAT ALLO APPE AUTH
CDUP CLNT CWD DELE EPRT
EPSV FEAT HASH HELP LIST
MDTM MFMT MKD MLSD MLST
MODE NLST NOOP OPTS PASS
PASV PBSZ PORT PROT PWD
QUIT REST RETR RMD RNFR
RNTO SITE SIZE STOR STOU
SYST TYPE USER

Parameters is a string containing any parameters following the command sent by the client, such as a username following the USER command. The string contains all characters following the command itself and the next space.

The Response will be sent back to the client and is determined by the custom command and server logic.

Connected Event (FTPServer Class)

This event fires immediately after a connection completes (or fails).

Syntax

public class DefaultFTPServerEventListener implements FTPServerEventListener {
  ...
  public void connected(FTPServerConnectedEvent e) {}
  ...
}

public class FTPServerConnectedEvent {
  public String connectionId;
}

Remarks

This event fires at the end of the connection process. It fires again for Secure Sockets Layer (SSL) negotiation.

The ConnectionId is the Id of the connected client that caused the event to fire.

ConnectionRequest Event (FTPServer Class)

This event fires when a client makes a connection request.

Syntax

public class DefaultFTPServerEventListener implements FTPServerEventListener {
  ...
  public void connectionRequest(FTPServerConnectionRequestEvent e) {}
  ...
}

public class FTPServerConnectionRequestEvent {
  public String address;
  public int port;
  public boolean accept; //read-write
}

Remarks

This event indicates an incoming connection. The connection is accepted by default. Address and Port will contain information about the client requesting the inbound connection. If you want to refuse it, you can set the Accept parameter to False.

DirChange Event (FTPServer Class)

This event fires during processing of a directory change request.

Syntax

public class DefaultFTPServerEventListener implements FTPServerEventListener {
  ...
  public void dirChange(FTPServerDirChangeEvent e) {}
  ...
}

public class FTPServerDirChangeEvent {
  public String connectionId;
  public String oldDirectory;
  public String newDirectory;
  public boolean beforeExec;
  public int errorCode; //read-write
  public String errorDesc; //read-write
}

Remarks

This event is fired when the client requests that the working directory be changed.

The ConnectionId is the Id of the connected client that caused the event to fire.

OldDirectory is the previous working directory for this client, and NewDirectory is the working directory to change to. Both directories are paths with respect to the client's home directory.

BeforeExec and Custom Handling

This event is fired both before and after the requested operation is executed. The BeforeExec parameter will be True before execution by the class and False afterwords. Handling the event before execution provides an opportunity to use custom logic to determine whether the operation should be denied, diverted, or otherwise modified. Handling the event after execution provides an opportunity to process the results of the execution or set a custom value to be returned to the client.

NOTE: If ErrorCode is set to a non-zero value when BeforeExec is True, the class will not execute the operation and will send an error to the client. When BeforeExec is False, the values of ErrorCode and ErrorDesc will reflect the success or reason for failure of the executed operation. In either case, they may be set by the server to reflect the result of custom processing.

DirCreate Event (FTPServer Class)

This event fires during processing of a directory creation request.

Syntax

public class DefaultFTPServerEventListener implements FTPServerEventListener {
  ...
  public void dirCreate(FTPServerDirCreateEvent e) {}
  ...
}

public class FTPServerDirCreateEvent {
  public String connectionId;
  public String directory;
  public boolean beforeExec;
  public int errorCode; //read-write
  public String errorDesc; //read-write
}

Remarks

This event is fired when the client requests that a directory be created.

The ConnectionId is the Id of the connected client that caused the event to fire.

BeforeExec and Custom Handling

This event is fired both before and after the requested operation is executed. The BeforeExec parameter will be True before execution by the class and False afterwords. Handling the event before execution provides an opportunity to use custom logic to determine whether the operation should be denied, diverted, or otherwise modified. Handling the event after execution provides an opportunity to process the results of the execution or set a custom value to be returned to the client.

NOTE: If ErrorCode is set to a non-zero value when BeforeExec is True, the class will not execute the operation and will send an error to the client. When BeforeExec is False, the values of ErrorCode and ErrorDesc will reflect the success or reason for failure of the executed operation. In either case, they may be set by the server to reflect the result of custom processing.

DirList Event (FTPServer Class)

This event fires during processing of a directory list request.

Syntax

public class DefaultFTPServerEventListener implements FTPServerEventListener {
  ...
  public void dirList(FTPServerDirListEvent e) {}
  ...
}

public class FTPServerDirListEvent {
  public String connectionId;
  public String directory;
  public String command;
  public boolean beforeExec;
  public String localDir; //read-write
  public String response; //read-write
  public int errorCode; //read-write
  public String errorDesc; //read-write
}

Remarks

This event is fired when the client requests that the given LocalDir contents be listed.

Directory is the directory to list specified in the command sent by the client. Its value is a virtual path relative to the local root directory for the client.

LocalDir is the full local path of the directory the class will list when it executes the operation. By default, its value is a full path equivalent to the virtual path specified by Directory. However, it may be changed when BeforeExec is True to make the class retrieve list data for the LocalDir value rather than for the one requested by the client. This is especially useful for a virtual filesystem application, in which case the client is requesting lists for directories that do not actually exist at the location specified.

The Response is the directory list data to be sent to the client. Its contents are set automatically during the execution of the list operation by the class, and also can be set manually before or after execution. If set when BeforeExec is True, the class will not execute the operation.

The server also may add directory entries to be sent to the client in the Response using the AddDirEntry method. If entries are added using this method during the first firing of the event, the only entries returned to the client will be the ones added manually. The class will not perform the normal processing of the list request, and the event will not fire a second time.

If no directory is added and no Response or ErrorCode is set during the first time the event fires, the class will process the directory list normally and any entries that exist in the given directory will be sent to the client. Additional entries may be added by calling AddDirEntry during the second firing of the event. In this case, both the automatically and manually added entries will be sent to the client.

The Command argument can be used to determine which parameters need to be specified in the AddDirEntry method. Possible value are MLST, NLST, MLSD, and LIST. For details on usage and which parameters are applicable to which commands, see AddDirEntry.

The ConnectionId is the Id of the connected client that caused the event to fire.

BeforeExec and Custom Handling

This event is fired both before and after the requested operation is executed. The BeforeExec parameter will be True before execution by the class and False afterwords. Handling the event before execution provides an opportunity to use custom logic to determine whether the operation should be denied, diverted, or otherwise modified. Handling the event after execution provides an opportunity to process the results of the execution or set a custom value to be returned to the client.

NOTE: If ErrorCode is set to a non-zero value when BeforeExec is True, the class will not execute the operation and will send an error to the client. When BeforeExec is False, the values of ErrorCode and ErrorDesc will reflect the success or reason for failure of the executed operation. In either case, they may be set by the server to reflect the result of custom processing.

DirRemove Event (FTPServer Class)

This event fires during processing of a directory remove request.

Syntax

public class DefaultFTPServerEventListener implements FTPServerEventListener {
  ...
  public void dirRemove(FTPServerDirRemoveEvent e) {}
  ...
}

public class FTPServerDirRemoveEvent {
  public String connectionId;
  public String directory;
  public boolean beforeExec;
  public int errorCode; //read-write
  public String errorDesc; //read-write
}

Remarks

This event is fired when a client requests the given Directory be removed from the server.

The ConnectionId is the Id of the connected client that caused the event to fire.

BeforeExec and Custom Handling

This event is fired both before and after the requested operation is executed. The BeforeExec parameter will be True before execution by the class and False afterwords. Handling the event before execution provides an opportunity to use custom logic to determine whether the operation should be denied, diverted, or otherwise modified. Handling the event after execution provides an opportunity to process the results of the execution or set a custom value to be returned to the client.

NOTE: If ErrorCode is set to a non-zero value when BeforeExec is True, the class will not execute the operation and will send an error to the client. When BeforeExec is False, the values of ErrorCode and ErrorDesc will reflect the success or reason for failure of the executed operation. In either case, they may be set by the server to reflect the result of custom processing.

Disconnected Event (FTPServer Class)

This event fires when a client is disconnected.

Syntax

public class DefaultFTPServerEventListener implements FTPServerEventListener {
  ...
  public void disconnected(FTPServerDisconnectedEvent e) {}
  ...
}

public class FTPServerDisconnectedEvent {
  public String connectionId;
}

Remarks

This event is fired when a client logs off or is disconnected by the server.

The ConnectionId is the Id of the connected client that caused the event to fire.

EndTransfer Event (FTPServer Class)

This event fires when a transfer of data ends.

Syntax

public class DefaultFTPServerEventListener implements FTPServerEventListener {
  ...
  public void endTransfer(FTPServerEndTransferEvent e) {}
  ...
}

public class FTPServerEndTransferEvent {
  public String connectionId;
  public String fileName;
  public int direction;
  public int errorCode;
  public String errorDesc;
}

Remarks

This event is fired at the end of the upload or download of a file FileName. See FileDownload and FileUpload for details on the steps to process transfer requests.

The ConnectionId is the Id of the connected client that caused the event to fire.

The Direction parameter shows whether the client (0) or the server (1) is sending the data.

The values of ErrorCode and ErrorDesc will be non-zero and non-empty, respectively, if any error occurred during the transfer. For a list of valid error codes and their descriptions, please refer to the Error Codes section.

Error Event (FTPServer Class)

This includes information about errors during data delivery.

Syntax

public class DefaultFTPServerEventListener implements FTPServerEventListener {
  ...
  public void error(FTPServerErrorEvent e) {}
  ...
}

public class FTPServerErrorEvent {
  public String connectionId;
  public int errorCode;
  public String description;
}

Remarks

The Error event is fired in case of exceptional conditions during message processing. Normally, the class throws an exception.

ConnectionId is the associated client Id, ErrorCode contains an error code, and Description contains a textual description of the error. For a list of valid error codes and their descriptions, please refer to the Error Codes section.

FileDelete Event (FTPServer Class)

This event fires during processing of a file delete request.

Syntax

public class DefaultFTPServerEventListener implements FTPServerEventListener {
  ...
  public void fileDelete(FTPServerFileDeleteEvent e) {}
  ...
}

public class FTPServerFileDeleteEvent {
  public String connectionId;
  public String fileName;
  public boolean beforeExec;
  public int errorCode; //read-write
  public String errorDesc; //read-write
}

Remarks

This event is fired when a client requests that a file FileName be deleted from the server.

The ConnectionId is the Id of the connected client that caused the event to fire.

BeforeExec and Custom Handling

This event is fired both before and after the requested operation is executed. The BeforeExec parameter will be True before execution by the class and False afterwords. Handling the event before execution provides an opportunity to use custom logic to determine whether the operation should be denied, diverted, or otherwise modified. Handling the event after execution provides an opportunity to process the results of the execution or set a custom value to be returned to the client.

NOTE: If ErrorCode is set to a non-zero value when BeforeExec is True, the class will not execute the operation and will send an error to the client. When BeforeExec is False, the values of ErrorCode and ErrorDesc will reflect the success or reason for failure of the executed operation. In either case, they may be set by the server to reflect the result of custom processing.

FileDownload Event (FTPServer Class)

This event fires during processing of a file download request.

Syntax

public class DefaultFTPServerEventListener implements FTPServerEventListener {
  ...
  public void fileDownload(FTPServerFileDownloadEvent e) {}
  ...
}

public class FTPServerFileDownloadEvent {
  public String connectionId;
  public String fileName;
  public long startByte;
  public boolean beforeExec;
  public String localFile; //read-write
  public int errorCode; //read-write
  public String errorDesc; //read-write
}

Remarks

This event is fired when a client requests that a file be transferred to it from the server.

When BeforeExec is True, the event parameters can be used to determine whether to allow the download, inform the client of any error, and specify a file or stream for the download other than the one given by FileName.

The default behavior is for the component to download the file FileName if it exists and to return an invalid path error otherwise. However, the server may use the FileName and ConnectionId to determine whether or not it wishes to allow the download, and which file to actually transfer.

You can transfer a file not located at the path referenced by FileName, such as in the case of "virtual" files, in the following three ways:

  • The FileData field of the FTPConnection object associated with the client making the transfer request: simply set this field equal to the data the server should transfer to the client. It can be used only from within this event. See the FTPConnection type for details.
  • The SetInputStream method: passes a file stream to be used for the download. See the method documentation for details.
  • The LocalFile event argument: specifies the full path to the file on disk from which the class will read data when sending content back to the connected client. This may be modified within this event when BeforeExec is True to instruct the class to transfer a different local file than the one referenced by FileName.

The ConnectionId is the Id of the connected client that caused the event to fire.

The StartByte parameter specifies the index of the byte at which the download should start and is used when the client requests that a download be restarted from a certain point.

Download Request Processing Steps

  1. A RETR command is received by the class from a client.
  2. The class sends a "150 opening data channel for file download" message.
  3. The FileDownload event is fired for the first time with BeforeExec set to True.
  4. The StartTransfer event is fired when the transfer of data actually begins.
  5. The Transfer event is fired repeatedly as bytes are transferred.
  6. The EndTransfer event is fired when the transfer of data is complete.
  7. The FileDownload event is fired for the second time with BeforeExec set to False.
  8. The class sends a "226 Successfully transferred" message.

BeforeExec and Custom Handling

This event is fired both before and after the requested operation is executed. The BeforeExec parameter will be True before execution by the class and False afterwords. Handling the event before execution provides an opportunity to use custom logic to determine whether the operation should be denied, diverted, or otherwise modified. Handling the event after execution provides an opportunity to process the results of the execution or set a custom value to be returned to the client.

NOTE: If ErrorCode is set to a non-zero value when BeforeExec is True, the class will not execute the operation and will send an error to the client. When BeforeExec is False, the values of ErrorCode and ErrorDesc will reflect the success or reason for failure of the executed operation. In either case, they may be set by the server to reflect the result of custom processing.

FileGetModifiedTime Event (FTPServer Class)

This event fires during processing of an MDTM command.

Syntax

public class DefaultFTPServerEventListener implements FTPServerEventListener {
  ...
  public void fileGetModifiedTime(FTPServerFileGetModifiedTimeEvent e) {}
  ...
}

public class FTPServerFileGetModifiedTimeEvent {
  public String connectionId;
  public String fileName;
  public boolean beforeExec;
  public String response; //read-write
  public int errorCode; //read-write
  public String errorDesc; //read-write
}

Remarks

This event is fired when the client requests that the class calculate the modified time of a file.

FileName holds the filename for which the client has requested the size.

Response should hold the modified time of the file. The format of the modified time must be yyyyMMddHHmmss.SSS, but the "." and subsequent digits (sss) are optional. Time values are always represented in UTC. If the file exists on disk, the class will automatically populate this value during execution, and it will be available when BeforeExec is False.

Response may be set manually before or after execution, but if it is set before, the class will not calculate the modified time, and the event will not fire a second time.

The ConnectionId is the Id of the connected client that caused the event to fire.

BeforeExec and Custom Handling

This event is fired both before and after the requested operation is executed. The BeforeExec parameter will be True before execution by the class and False afterwords. Handling the event before execution provides an opportunity to use custom logic to determine whether the operation should be denied, diverted, or otherwise modified. Handling the event after execution provides an opportunity to process the results of the execution or set a custom value to be returned to the client.

NOTE: If ErrorCode is set to a non-zero value when BeforeExec is True, the class will not execute the operation and will send an error to the client. When BeforeExec is False, the values of ErrorCode and ErrorDesc will reflect the success or reason for failure of the executed operation. In either case, they may be set by the server to reflect the result of custom processing.

FileGetSize Event (FTPServer Class)

This event fires during processing of a SIZE command.

Syntax

public class DefaultFTPServerEventListener implements FTPServerEventListener {
  ...
  public void fileGetSize(FTPServerFileGetSizeEvent e) {}
  ...
}

public class FTPServerFileGetSizeEvent {
  public String connectionId;
  public String fileName;
  public boolean beforeExec;
  public String response; //read-write
  public int errorCode; //read-write
  public String errorDesc; //read-write
}

Remarks

This event is fired when a client requests that the server calculate the size of a file.

FileName holds the filename for which the client has requested the size.

Response should hold the length of the file in bytes. If the file exists on disk, the class will automatically populate this value, and it will be available when BeforeExec is False.

Response may be set manually before or after execution, but if it is set before, the class will not calculate the size, and the event will not fire a second time.

The ConnectionId is the Id of the connected client that caused the event to fire.

BeforeExec and Custom Handling

This event is fired both before and after the requested operation is executed. The BeforeExec parameter will be True before execution by the class and False afterwords. Handling the event before execution provides an opportunity to use custom logic to determine whether the operation should be denied, diverted, or otherwise modified. Handling the event after execution provides an opportunity to process the results of the execution or set a custom value to be returned to the client.

NOTE: If ErrorCode is set to a non-zero value when BeforeExec is True, the class will not execute the operation and will send an error to the client. When BeforeExec is False, the values of ErrorCode and ErrorDesc will reflect the success or reason for failure of the executed operation. In either case, they may be set by the server to reflect the result of custom processing.

FileRename Event (FTPServer Class)

This event fires during processing of a file rename request.

Syntax

public class DefaultFTPServerEventListener implements FTPServerEventListener {
  ...
  public void fileRename(FTPServerFileRenameEvent e) {}
  ...
}

public class FTPServerFileRenameEvent {
  public String connectionId;
  public String oldFileName;
  public String newFileName;
  public boolean beforeExec;
  public int errorCode; //read-write
  public String errorDesc; //read-write
}

Remarks

This event is fired when a client requests that a file on the server be renamed.

The ConnectionId is the Id of the connected client that caused the event to fire.

OldFileName is the previous name of the file to rename, and NewFileName is the new file name.

BeforeExec and Custom Handling

This event is fired both before and after the requested operation is executed. The BeforeExec parameter will be True before execution by the class and False afterwords. Handling the event before execution provides an opportunity to use custom logic to determine whether the operation should be denied, diverted, or otherwise modified. Handling the event after execution provides an opportunity to process the results of the execution or set a custom value to be returned to the client.

NOTE: If ErrorCode is set to a non-zero value when BeforeExec is True, the class will not execute the operation and will send an error to the client. When BeforeExec is False, the values of ErrorCode and ErrorDesc will reflect the success or reason for failure of the executed operation. In either case, they may be set by the server to reflect the result of custom processing.

FileUpload Event (FTPServer Class)

This event fires during processing of a file upload request.

Syntax

public class DefaultFTPServerEventListener implements FTPServerEventListener {
  ...
  public void fileUpload(FTPServerFileUploadEvent e) {}
  ...
}

public class FTPServerFileUploadEvent {
  public String connectionId;
  public String fileName;
  public long startByte;
  public boolean isAppend;
  public boolean isStoreUnique;
  public boolean beforeExec;
  public String localFile; //read-write
  public int errorCode; //read-write
  public String errorDesc; //read-write
}

Remarks

This event is fired when a client requests that a file be transferred from it to the server.

When BeforeExec is True, and the arguments can be used to determine whether to allow the upload, inform the client of any error, and specify a file or stream for the upload other than the one given by FileName.

The default behavior is for the component to upload the file FileName if it exists and the user is permitted to upload, and to return an invalid path error otherwise. However, the server may use the FileName, ConnectionId, and other arguments to determine whether or not it wishes to allow the upload, and the location to actually upload the file to.

You can upload a file to a location other than the one referenced by FileName, such as in the case of "virtual" files, in the following three ways:

  • The FileData field of the FTPConnection object associated with the client making the transfer request: the data uploaded will be saved in this field rather than written to disk. To use this method, first set the LocalFile parameter to an empty string to indicate the data will not be written to any disk location. When EndTransfer fires the field will then contain the uploaded file data.
  • The SetOutputStream method: passes a file stream to be used for the upload. See the method documentation for details.
  • The LocalFile event argument: specifies the full path to the file on disk to which the class will write data when receiving content from the connected client. This may be modified within this event when BeforeExec is True to instruct the class to use a different local file.

The ConnectionId is the Id of the connected client that caused the event to fire.

The StartByte parameter specifies the index of the byte at which the upload should start and is used when the client requests that an upload be restarted from a certain point.

Upload Request Processing Steps

  1. A STOR, APPE or STOU command is received by the class from a client.
  2. The class sends a "150 opening data channel for file upload" message.
  3. The FileUpload event is fired for the first time with BeforeExec set to True.
  4. The StartTransfer event is fired when the transfer of data actually begins.
  5. The Transfer event is fired repeatedly as bytes are transferred.
  6. The EndTransfer event is fired when the transfer of data is complete.
  7. The FileUpload event is fired for the second time with BeforeExec set to False.
  8. The class sends a "226 Successfully transferred" message.

BeforeExec and Custom Handling

This event is fired both before and after the requested operation is executed. The BeforeExec parameter will be True before execution by the class and False afterwords. Handling the event before execution provides an opportunity to use custom logic to determine whether the operation should be denied, diverted, or otherwise modified. Handling the event after execution provides an opportunity to process the results of the execution or set a custom value to be returned to the client.

NOTE: If ErrorCode is set to a non-zero value when BeforeExec is True, the class will not execute the operation and will send an error to the client. When BeforeExec is False, the values of ErrorCode and ErrorDesc will reflect the success or reason for failure of the executed operation. In either case, they may be set by the server to reflect the result of custom processing.

Log Event (FTPServer Class)

This event fires once for each log message.

Syntax

public class DefaultFTPServerEventListener implements FTPServerEventListener {
  ...
  public void log(FTPServerLogEvent e) {}
  ...
}

public class FTPServerLogEvent {
  public String connectionId;
  public int logLevel;
  public String message;
  public String logType;
}

Remarks

This event fires once for each log message generated by the class. The verbosity is controlled by the LogLevel setting.

LogLevel indicates the level of message. Possible values are as follows:

0 (None) No events are logged.
1 (Info - default) Informational events are logged.
2 (Verbose) Detailed data are logged.
3 (Debug) Debug data are logged.

The value 1 (Info) logs basic information, including users logging in and out, files transferred, and directories listed.

The value 2 (Verbose) includes logs from the PITrail event as well as basic information about data transfer channels.

The value 3 (Debug) logs additional debug information, such as extended socket connection and data transfer information.

Message is the log entry.

LogType identifies the type of log entry. Possible values are as follows:

  • "Info"
  • "Error"
  • "Verbose"
  • "Debug"
  • "PITrail"

PITrail Event (FTPServer Class)

This event traces the commands sent to the server, and the respective replies.

Syntax

public class DefaultFTPServerEventListener implements FTPServerEventListener {
  ...
  public void PITrail(FTPServerPITrailEvent e) {}
  ...
}

public class FTPServerPITrailEvent {
  public String connectionId;
  public int direction;
  public String message;
}

Remarks

The PITrail event is useful for debugging purposes. It shows all the interaction between the client and the server, line by line.

The Message parameter contains the full text of the message. The Direction parameter shows the originator of the message:

0 (Client)The Message originates from the client.
1 (Server)The Message originates from the server.
2 (Info)The Message is an informative message originating from the client software (the class code).

NOTE: PITrail output is also included in the Log event when the LogLevel configuration setting is set to "Verbose" (2) or higher.

SSLClientAuthentication Event (FTPServer Class)

This event fires when the client presents its credentials to the server.

Syntax

public class DefaultFTPServerEventListener implements FTPServerEventListener {
  ...
  public void SSLClientAuthentication(FTPServerSSLClientAuthenticationEvent e) {}
  ...
}

public class FTPServerSSLClientAuthenticationEvent {
  public String connectionId;
  public byte[] certEncoded;
  public String certSubject;
  public String certIssuer;
  public String status;
  public boolean accept; //read-write
}

Remarks

The server can decide whether or not to continue. The Accept parameter is a recommendation on whether to continue or close the connection. This is just a suggestion: application software must use its own logic to determine whether or not to continue.

When Accept is False, Status shows why the verification failed; otherwise, Status contains the string "OK".

SSLConnectionRequest Event (FTPServer Class)

This event fires when an SSL connection is requested.

Syntax

public class DefaultFTPServerEventListener implements FTPServerEventListener {
  ...
  public void SSLConnectionRequest(FTPServerSSLConnectionRequestEvent e) {}
  ...
}

public class FTPServerSSLConnectionRequestEvent {
  public String connectionId;
  public String supportedCipherSuites;
  public String supportedSignatureAlgs;
  public int certStoreType; //read-write
  public String certStore; //read-write
  public String certPassword; //read-write
  public String certSubject; //read-write
}

Remarks

This event fires when an SSL connection is requested and SSLProvider is set to Internal. This event provides an opportunity to select an alternative certificate to the connecting client. This event does not fire when SSLProvider is set to Platform.

This event allows the class to be configured to use both RSA and ECDSA certificates depending on the connecting client's capabilities.

ConnectionId is the connection Id of the client requesting the connection.

SupportedCipherSuites is a comma-separated list of cipher suites that the client supports.

SupportedSignatureAlgs is a comma-separated list of certificate signature algorithms that the client supports.

CertStoreType is the store type of the alternate certificate to use for this connection. The class supports both public and private keys in a variety of formats. When the cstAuto value is used, the class will automatically determine the type. This field can take one of the following values:

0 (cstUser - default)For Windows, this specifies that the certificate store is a certificate store owned by the current user.

NOTE: This store type is not available in Java.

1 (cstMachine)For Windows, this specifies that the certificate store is a machine store.

NOTE: This store type is not available in Java.

2 (cstPFXFile)The certificate store is the name of a PFX (PKCS#12) file containing certificates.
3 (cstPFXBlob)The certificate store is a string (binary or Base64-encoded) representing a certificate store in PFX (PKCS#12) format.
4 (cstJKSFile)The certificate store is the name of a Java Key Store (JKS) file containing certificates.

NOTE: This store type is only available in Java.

5 (cstJKSBlob)The certificate store is a string (binary or Base64-encoded) representing a certificate store in Java Key Store (JKS) format.

NOTE: This store type is only available in Java.

6 (cstPEMKeyFile)The certificate store is the name of a PEM-encoded file that contains a private key and an optional certificate.
7 (cstPEMKeyBlob)The certificate store is a string (binary or Base64-encoded) that contains a private key and an optional certificate.
8 (cstPublicKeyFile)The certificate store is the name of a file that contains a PEM- or DER-encoded public key certificate.
9 (cstPublicKeyBlob)The certificate store is a string (binary or Base64-encoded) that contains a PEM- or DER-encoded public key certificate.
10 (cstSSHPublicKeyBlob)The certificate store is a string (binary or Base64-encoded) that contains an SSH-style public key.
11 (cstP7BFile)The certificate store is the name of a PKCS#7 file containing certificates.
12 (cstP7BBlob)The certificate store is a string (binary) representing a certificate store in PKCS#7 format.
13 (cstSSHPublicKeyFile)The certificate store is the name of a file that contains an SSH-style public key.
14 (cstPPKFile)The certificate store is the name of a file that contains a PPK (PuTTY Private Key).
15 (cstPPKBlob)The certificate store is a string (binary) that contains a PPK (PuTTY Private Key).
16 (cstXMLFile)The certificate store is the name of a file that contains a certificate in XML format.
17 (cstXMLBlob)The certificate store is a string that contains a certificate in XML format.
18 (cstJWKFile)The certificate store is the name of a file that contains a JWK (JSON Web Key).
19 (cstJWKBlob)The certificate store is a string that contains a JWK (JSON Web Key).
21 (cstBCFKSFile)The certificate store is the name of a file that contains a BCFKS (Bouncy Castle FIPS Key Store).

NOTE: This store type is only available in Java and .NET.

22 (cstBCFKSBlob)The certificate store is a string (binary or Base64-encoded) representing a certificate store in BCFKS (Bouncy Castle FIPS Key Store) format.

NOTE: This store type is only available in Java and .NET.

23 (cstPKCS11)The certificate is present on a physical security key accessible via a PKCS#11 interface.

To use a security key, create a new Certificate object and pass cstPKCS11 as the StoreType, the full path of the PKCS#11 DLL as the Store, and the PIN as the StorePassword.

Code Example. SSH Authentication with Security Key (without CertMgr): sftp.SSHCert = new Certificate(CertStoreTypes.cstPKCS11, @"C:\Program Files\OpenSC Project\OpenSC\pkcs11\opensc-pkcs11.dll", "123456", // PIN "CN=cert_subject"); sftp.SSHUser = "test"; sftp.SSHLogon("myhost", 22);

Alternatively, collect the necessary data using the CertMgr class by calling the ListStoreCertificates method after setting the corresponding properties accordingly. The certificate information returned in the CertList event's CertEncoded parameter may be saved for later use.

When using a certificate obtained with this approach, pass the previously saved security key information as the Store and set StorePassword to the PIN.

Code Example. SSH Authentication with Security Key (with CertMgr): certmgr.CertStoreType = CertStoreTypes.cstPKCS11; certmgr.OnCertList += (s, e) => { secKeyBlob = e.CertEncoded; }; certmgr.CertStore = @"C:\Program Files\OpenSC Project\OpenSC\pkcs11\opensc-pkcs11.dll"; certmgr.CertStorePassword = "123456"; // PIN certmgr.ListStoreCertificates(); sftp.SSHCert = new Certificate(CertStoreTypes.cstPKCS11, secKeyBlob, "123456", "*"); sftp.SSHUser = "test"; sftp.SSHLogon("myhost", 22);

99 (cstAuto)The store type is automatically detected from the input data. This setting may be used with both public and private keys and can detect any of the supported formats automatically.

CertStore is the store name or location of the alternate certificate to use for this connection.

Designations of certificate stores are platform dependent.

The following designations are the most common User and Machine certificate stores in Windows:

MYA certificate store holding personal certificates with their associated private keys.
CACertifying authority certificates.
ROOTRoot certificates.

In Java, the certificate store normally is a file containing certificates and optional private keys.

When the certificate store type is cstPFXFile, this property must be set to the name of the file. When the type is cstPFXBlob, the property must be set to the binary contents of a PFX file (i.e., PKCS#12 certificate store).

CertPassword is the password of the certificate store containing the alternate certificate to use for this connection.

CertSubject is the subject of the alternate certificate to use for this connection.

The special value * matches any subject and will select the first certificate in the store. The certificate subject is a comma-separated list of distinguished name fields and values. For instance, "CN=www.server.com, OU=test, C=US, E=example@email.com". Common fields and their meanings are as follows:

FieldMeaning
CNCommon Name. This is commonly a hostname like www.server.com.
OOrganization
OUOrganizational Unit
LLocality
SState
CCountry
EEmail Address

If a field value contains a comma, it must be quoted.

SSLStatus Event (FTPServer Class)

This event shows the progress of the secure connection.

Syntax

public class DefaultFTPServerEventListener implements FTPServerEventListener {
  ...
  public void SSLStatus(FTPServerSSLStatusEvent e) {}
  ...
}

public class FTPServerSSLStatusEvent {
  public String connectionId;
  public String message;
}

Remarks

The event is fired for informational and logging purposes only. It is used to track the progress of the connection.

StartTransfer Event (FTPServer Class)

This event fires when a transfer of data begins.

Syntax

public class DefaultFTPServerEventListener implements FTPServerEventListener {
  ...
  public void startTransfer(FTPServerStartTransferEvent e) {}
  ...
}

public class FTPServerStartTransferEvent {
  public String connectionId;
  public String fileName;
  public int direction;
}

Remarks

This event fires at the start of the upload or download of a file FileName. See FileDownload and FileUpload for details on steps in the processing of transfer requests.

The ConnectionId is the Id of the connected client that caused the event to fire.

The Direction parameter shows whether the client (0) or the server (1) is sending the data.

Transfer Event (FTPServer Class)

This event fires when bytes are transferred.

Syntax

public class DefaultFTPServerEventListener implements FTPServerEventListener {
  ...
  public void transfer(FTPServerTransferEvent e) {}
  ...
}

public class FTPServerTransferEvent {
  public String connectionId;
  public String fileName;
  public int direction;
  public long bytesTransferred;
  public byte[] text;
}

Remarks

This event fires repeatedly as bytes are transferred between client and server. See FileDownload and FileUpload for details on steps in the processing of transfer requests.

The BytesTransferred parameter shows the number of bytes transferred since the beginning of the transfer.

Text contains the portion of the file data being delivered.

The Direction parameter shows whether the client (0) or the server (1) is sending the data.

NOTE: Events are not re-entrant. Performing time-consuming operations within this event will prevent it from firing again in a timely manner and may affect overall performance.

UserAuthentication Event (FTPServer Class)

This event fires when a client provides login credentials to the server.

Syntax

public class DefaultFTPServerEventListener implements FTPServerEventListener {
  ...
  public void userAuthentication(FTPServerUserAuthenticationEvent e) {}
  ...
}

public class FTPServerUserAuthenticationEvent {
  public String connectionId;
  public String address;
  public int port;
  public String user;
  public String password;
  public String rootDir; //read-write
  public String homeDir; //read-write
  public boolean accept; //read-write
}

Remarks

This event fires when the PASS command is received for the user currently attempting to connect. This event allows the server to use its own logic to decide whether to accept or reject a client connection based on their user credentials and connection information.

Accept can be set to control if the class should proceed with the connection for the user. By default, Accept will be True if the user credentials provided are in the Users collection and otherwise will be False. In either case, the value may be set within the method based on application logic to override this default authentication behavior. Such a change will be applied only to the current connection and not to future connections for this user.

RootDir is the local root directory for the user. If the credentials for this User have been added to Users, its default value will be the value specified in the call to AddUser. Otherwise, its default value will be DefaultRootDir. To set a different root for this connection, change the value of RootDir in this event. Such a change will be applied only to the current connection and not to future connections for this user.

HomeDir is the directory that will be the initial working directory for the user upon login. To use the same location as the RootDir, set it to an empty string or /. Otherwise, this value must be a virtual path relative to RootDir (or DefaultRootDir if applicable). Users may navigate up from their HomeDir as long as they do not navigate above their RootDir, which they are not able to leave. An example of the meanings of the two values follows:

RootDir HomeDir Full local home path
C:/FTPServer /Users/Me C:/FTPServer/Users/Me
can be set to a custom value for this user in this event based on application logic. If the credentials for this User have been added to Users, its default value will be the value specified in the call to AddUser. Otherwise, its default value will be /. To set a different home directory for this connection, change the value of HomeDir in this event.

Address and Port are the address and port of the client attempting authentication.

User and Password are the credentials of the client attempting authentication.

The ConnectionId is the Id of the connected client that caused the event to fire.

Certificate Type

This is the digital certificate being used.

Remarks

This type describes the current digital certificate. The certificate may be a public or private key. The fields are used to identify or select certificates.

The following fields are available:

Fields

EffectiveDate
String (read-only)

Default Value: ""

The date on which this certificate becomes valid. Before this date, it is not valid. The date is localized to the system's time zone. The following example illustrates the format of an encoded date:

23-Jan-2000 15:00:00.

ExpirationDate
String (read-only)

Default Value: ""

The date on which the certificate expires. After this date, the certificate will no longer be valid. The date is localized to the system's time zone. The following example illustrates the format of an encoded date:

23-Jan-2001 15:00:00.

ExtendedKeyUsage
String (read-only)

Default Value: ""

A comma-delimited list of extended key usage identifiers. These are the same as ASN.1 object identifiers (OIDs).

Fingerprint
String (read-only)

Default Value: ""

The hex-encoded, 16-byte MD5 fingerprint of the certificate. This property is primarily used for keys which do not have a corresponding X.509 public certificate, such as PEM keys that only contain a private key. It is commonly used for SSH keys.

The following example illustrates the format: bc:2a:72:af:fe:58:17:43:7a:5f:ba:5a:7c:90:f7:02

FingerprintSHA1
String (read-only)

Default Value: ""

The hex-encoded, 20-byte SHA-1 fingerprint of the certificate. This property is primarily used for keys which do not have a corresponding X.509 public certificate, such as PEM keys that only contain a private key. It is commonly used for SSH keys.

The following example illustrates the format: 30:7b:fa:38:65:83:ff:da:b4:4e:07:3f:17:b8:a4:ed:80:be:ff:84

FingerprintSHA256
String (read-only)

Default Value: ""

The hex-encoded, 32-byte SHA-256 fingerprint of the certificate. This property is primarily used for keys which do not have a corresponding X.509 public certificate, such as PEM keys that only contain a private key. It is commonly used for SSH keys.

The following example illustrates the format: 6a:80:5c:33:a9:43:ea:b0:96:12:8a:64:96:30:ef:4a:8a:96:86:ce:f4:c7:be:10:24:8e:2b:60:9e:f3:59:53

Issuer
String (read-only)

Default Value: ""

The issuer of the certificate. This field contains a string representation of the name of the issuing authority for the certificate.

KeyPassword
String

Default Value: ""

The password for the certificate's private key (if any).

Some certificate stores may individually protect certificates' private keys, separate from the standard protection offered by the StorePassword. This field can be used to read such password-protected private keys.

NOTE: This property defaults to the value of StorePassword. To clear it, you must set the property to the empty string (""). It can be set at any time, but when the private key's password is different from the store's password, then it must be set before calling PrivateKey.

PrivateKey
String (read-only)

Default Value: ""

The private key of the certificate (if available). The key is provided as PEM/Base64-encoded data.

NOTE: The PrivateKey may be available but not exportable. In this case, PrivateKey returns an empty string.

PrivateKeyAvailable
boolean (read-only)

Default Value: False

Whether a PrivateKey is available for the selected certificate. If PrivateKeyAvailable is True, the certificate may be used for authentication purposes (e.g., server authentication).

PrivateKeyContainer
String (read-only)

Default Value: ""

The name of the PrivateKey container for the certificate (if available). This functionality is available only on Windows platforms.

PublicKey
String (read-only)

Default Value: ""

The public key of the certificate. The key is provided as PEM/Base64-encoded data.

PublicKeyAlgorithm
String (read-only)

Default Value: ""

The textual description of the certificate's public key algorithm. The property contains either the name of the algorithm (e.g., "RSA" or "RSA_DH") or an object identifier (OID) string representing the algorithm.

PublicKeyLength
int (read-only)

Default Value: 0

The length of the certificate's public key (in bits). Common values are 512, 1024, and 2048.

SerialNumber
String (read-only)

Default Value: ""

The serial number of the certificate encoded as a string. The number is encoded as a series of hexadecimal digits, with each pair representing a byte of the serial number.

SignatureAlgorithm
String (read-only)

Default Value: ""

The text description of the certificate's signature algorithm. The property contains either the name of the algorithm (e.g., "RSA" or "RSA_MD5RSA") or an object identifier (OID) string representing the algorithm.

Store
String

Default Value: "MY"

The name of the certificate store for the client certificate.

The StoreType field denotes the type of the certificate store specified by Store. If the store is password-protected, specify the password in StorePassword.

Store is used in conjunction with the Subject field to specify client certificates. If Store has a value, and Subject or Encoded is set, a search for a certificate is initiated. Please see the Subject field for details.

Designations of certificate stores are platform dependent.

The following designations are the most common User and Machine certificate stores in Windows:

MYA certificate store holding personal certificates with their associated private keys.
CACertifying authority certificates.
ROOTRoot certificates.

In Java, the certificate store normally is a file containing certificates and optional private keys.

When the certificate store type is cstPFXFile, this property must be set to the name of the file. When the type is cstPFXBlob, the property must be set to the binary contents of a PFX file (i.e., PKCS#12 certificate store).

StoreB
byte[]

Default Value: "MY"

The name of the certificate store for the client certificate.

The StoreType field denotes the type of the certificate store specified by Store. If the store is password-protected, specify the password in StorePassword.

Store is used in conjunction with the Subject field to specify client certificates. If Store has a value, and Subject or Encoded is set, a search for a certificate is initiated. Please see the Subject field for details.

Designations of certificate stores are platform dependent.

The following designations are the most common User and Machine certificate stores in Windows:

MYA certificate store holding personal certificates with their associated private keys.
CACertifying authority certificates.
ROOTRoot certificates.

In Java, the certificate store normally is a file containing certificates and optional private keys.

When the certificate store type is cstPFXFile, this property must be set to the name of the file. When the type is cstPFXBlob, the property must be set to the binary contents of a PFX file (i.e., PKCS#12 certificate store).

StorePassword
String

Default Value: ""

If the type of certificate store requires a password, this field is used to specify the password needed to open the certificate store.

StoreType
int

Default Value: 0

The type of certificate store for this certificate.

The class supports both public and private keys in a variety of formats. When the cstAuto value is used, the class will automatically determine the type. This field can take one of the following values:

0 (cstUser - default)For Windows, this specifies that the certificate store is a certificate store owned by the current user.

NOTE: This store type is not available in Java.

1 (cstMachine)For Windows, this specifies that the certificate store is a machine store.

NOTE: This store type is not available in Java.

2 (cstPFXFile)The certificate store is the name of a PFX (PKCS#12) file containing certificates.
3 (cstPFXBlob)The certificate store is a string (binary or Base64-encoded) representing a certificate store in PFX (PKCS#12) format.
4 (cstJKSFile)The certificate store is the name of a Java Key Store (JKS) file containing certificates.

NOTE: This store type is only available in Java.

5 (cstJKSBlob)The certificate store is a string (binary or Base64-encoded) representing a certificate store in Java Key Store (JKS) format.

NOTE: This store type is only available in Java.

6 (cstPEMKeyFile)The certificate store is the name of a PEM-encoded file that contains a private key and an optional certificate.
7 (cstPEMKeyBlob)The certificate store is a string (binary or Base64-encoded) that contains a private key and an optional certificate.
8 (cstPublicKeyFile)The certificate store is the name of a file that contains a PEM- or DER-encoded public key certificate.
9 (cstPublicKeyBlob)The certificate store is a string (binary or Base64-encoded) that contains a PEM- or DER-encoded public key certificate.
10 (cstSSHPublicKeyBlob)The certificate store is a string (binary or Base64-encoded) that contains an SSH-style public key.
11 (cstP7BFile)The certificate store is the name of a PKCS#7 file containing certificates.
12 (cstP7BBlob)The certificate store is a string (binary) representing a certificate store in PKCS#7 format.
13 (cstSSHPublicKeyFile)The certificate store is the name of a file that contains an SSH-style public key.
14 (cstPPKFile)The certificate store is the name of a file that contains a PPK (PuTTY Private Key).
15 (cstPPKBlob)The certificate store is a string (binary) that contains a PPK (PuTTY Private Key).
16 (cstXMLFile)The certificate store is the name of a file that contains a certificate in XML format.
17 (cstXMLBlob)The certificate store is a string that contains a certificate in XML format.
18 (cstJWKFile)The certificate store is the name of a file that contains a JWK (JSON Web Key).
19 (cstJWKBlob)The certificate store is a string that contains a JWK (JSON Web Key).
21 (cstBCFKSFile)The certificate store is the name of a file that contains a BCFKS (Bouncy Castle FIPS Key Store).

NOTE: This store type is only available in Java and .NET.

22 (cstBCFKSBlob)The certificate store is a string (binary or Base64-encoded) representing a certificate store in BCFKS (Bouncy Castle FIPS Key Store) format.

NOTE: This store type is only available in Java and .NET.

23 (cstPKCS11)The certificate is present on a physical security key accessible via a PKCS#11 interface.

To use a security key, create a new Certificate object and pass cstPKCS11 as the StoreType, the full path of the PKCS#11 DLL as the Store, and the PIN as the StorePassword.

Code Example. SSH Authentication with Security Key (without CertMgr): sftp.SSHCert = new Certificate(CertStoreTypes.cstPKCS11, @"C:\Program Files\OpenSC Project\OpenSC\pkcs11\opensc-pkcs11.dll", "123456", // PIN "CN=cert_subject"); sftp.SSHUser = "test"; sftp.SSHLogon("myhost", 22);

Alternatively, collect the necessary data using the CertMgr class by calling the ListStoreCertificates method after setting the corresponding properties accordingly. The certificate information returned in the CertList event's CertEncoded parameter may be saved for later use.

When using a certificate obtained with this approach, pass the previously saved security key information as the Store and set StorePassword to the PIN.

Code Example. SSH Authentication with Security Key (with CertMgr): certmgr.CertStoreType = CertStoreTypes.cstPKCS11; certmgr.OnCertList += (s, e) => { secKeyBlob = e.CertEncoded; }; certmgr.CertStore = @"C:\Program Files\OpenSC Project\OpenSC\pkcs11\opensc-pkcs11.dll"; certmgr.CertStorePassword = "123456"; // PIN certmgr.ListStoreCertificates(); sftp.SSHCert = new Certificate(CertStoreTypes.cstPKCS11, secKeyBlob, "123456", "*"); sftp.SSHUser = "test"; sftp.SSHLogon("myhost", 22);

99 (cstAuto)The store type is automatically detected from the input data. This setting may be used with both public and private keys and can detect any of the supported formats automatically.

SubjectAltNames
String (read-only)

Default Value: ""

Comma-separated lists of alternative subject names for the certificate.

ThumbprintMD5
String (read-only)

Default Value: ""

The MD5 hash of the certificate. It is primarily used for X.509 certificates. If the hash does not already exist, it is automatically computed.

ThumbprintSHA1
String (read-only)

Default Value: ""

The SHA-1 hash of the certificate. It is primarily used for X.509 certificates. If the hash does not already exist, it is automatically computed.

ThumbprintSHA256
String (read-only)

Default Value: ""

The SHA-256 hash of the certificate. It is primarily used for X.509 certificates. If the hash does not already exist, it is automatically computed.

Usage
String (read-only)

Default Value: ""

The text description of UsageFlags.

This value will be one or more of the following strings and will be separated by commas:

  • Digital Signature
  • Non-Repudiation
  • Key Encipherment
  • Data Encipherment
  • Key Agreement
  • Certificate Signing
  • CRL Signing
  • Encipher Only

If the provider is OpenSSL, the value is a comma-separated list of X.509 certificate extension names.

UsageFlags
int (read-only)

Default Value: 0

The flags that show intended use for the certificate. The value of UsageFlags is a combination of the following flags:

0x80Digital Signature
0x40Non-Repudiation
0x20Key Encipherment
0x10Data Encipherment
0x08Key Agreement
0x04Certificate Signing
0x02CRL Signing
0x01Encipher Only

Please see the Usage field for a text representation of UsageFlags.

This functionality currently is not available when the provider is OpenSSL.

Version
String (read-only)

Default Value: ""

The certificate's version number. The possible values are the strings "V1", "V2", and "V3".

Subject
String

Default Value: ""

The subject of the certificate used for client authentication.

This field will be populated with the full subject of the loaded certificate. When loading a certificate, the subject is used to locate the certificate in the store.

If an exact match is not found, the store is searched for subjects containing the value of the property.

If a match is still not found, the property is set to an empty string, and no certificate is selected.

The special value "*" picks a random certificate in the certificate store.

The certificate subject is a comma-separated list of distinguished name fields and values. For instance, "CN=www.server.com, OU=test, C=US, E=example@email.com". Common fields and their meanings are as follows:

FieldMeaning
CNCommon Name. This is commonly a hostname like www.server.com.
OOrganization
OUOrganizational Unit
LLocality
SState
CCountry
EEmail Address

If a field value contains a comma, it must be quoted.

Encoded
String

Default Value: ""

The certificate (PEM/Base64 encoded). This field is used to assign a specific certificate. The Store and Subject fields also may be used to specify a certificate.

When Encoded is set, a search is initiated in the current Store for the private key of the certificate. If the key is found, Subject is updated to reflect the full subject of the selected certificate; otherwise, Subject is set to an empty string.

EncodedB
byte[]

Default Value: ""

The certificate (PEM/Base64 encoded). This field is used to assign a specific certificate. The Store and Subject fields also may be used to specify a certificate.

When Encoded is set, a search is initiated in the current Store for the private key of the certificate. If the key is found, Subject is updated to reflect the full subject of the selected certificate; otherwise, Subject is set to an empty string.

Constructors

public Certificate();

Creates a instance whose properties can be set.

public Certificate(String certificateFile);

Opens CertificateFile and reads out the contents as an X.509 public key.

public Certificate(byte[] encoded);

Parses Encoded as an X.509 public key.

public Certificate(int storeType, String store, String storePassword, String subject);

StoreType identifies the type of certificate store to use. See for descriptions of the different certificate stores. Store is a file containing the certificate store. StorePassword is the password used to protect the store.

After the store has been successfully opened, the class will attempt to find the certificate identified by Subject . This can be either a complete or a substring match of the X.509 certificate's subject Distinguished Name (DN). The Subject parameter can also take an MD5, SHA-1, or SHA-256 thumbprint of the certificate to load in a "Thumbprint=value" format.

public Certificate(int storeType, String store, String storePassword, String subject, String configurationString);

StoreType identifies the type of certificate store to use. See for descriptions of the different certificate stores. Store is a file containing the certificate store. StorePassword is the password used to protect the store.

ConfigurationString is a newline-separated list of name-value pairs that may be used to modify the default behavior. Possible values include "PersistPFXKey", which shows whether or not the PFX key is persisted after performing operations with the private key. This correlates to the PKCS12_NO_PERSIST_KEY CryptoAPI option. The default value is True (the key is persisted). "Thumbprint" - an MD5, SHA-1, or SHA-256 thumbprint of the certificate to load. When specified, this value is used to select the certificate in the store. This is applicable to the cstUser , cstMachine , cstPublicKeyFile , and cstPFXFile store types. "UseInternalSecurityAPI" shows whether the platform (default) or the internal security API is used when performing certificate-related operations.

After the store has been successfully opened, the class will attempt to find the certificate identified by Subject . This can be either a complete or a substring match of the X.509 certificate's subject Distinguished Name (DN). The Subject parameter can also take an MD5, SHA-1, or SHA-256 thumbprint of the certificate to load in a "Thumbprint=value" format.

public Certificate(int storeType, String store, String storePassword, byte[] encoded);

StoreType identifies the type of certificate store to use. See for descriptions of the different certificate stores. Store is a file containing the certificate store. StorePassword is the password used to protect the store.

After the store has been successfully opened, the class will load Encoded as an X.509 certificate and search the opened store for a corresponding private key.

public Certificate(int storeType, byte[] store, String storePassword, String subject);

StoreType identifies the type of certificate store to use. See for descriptions of the different certificate stores. Store is a byte array containing the certificate data. StorePassword is the password used to protect the store.

After the store has been successfully opened, the class will attempt to find the certificate identified by Subject . This can be either a complete or a substring match of the X.509 certificate's subject Distinguished Name (DN). The Subject parameter can also take an MD5, SHA-1, or SHA-256 thumbprint of the certificate to load in a "Thumbprint=value" format.

public Certificate(int storeType, byte[] store, String storePassword, String subject, String configurationString);

StoreType identifies the type of certificate store to use. See for descriptions of the different certificate stores. Store is a byte array containing the certificate data. StorePassword is the password used to protect the store.

After the store has been successfully opened, the class will attempt to find the certificate identified by Subject . This can be either a complete or a substring match of the X.509 certificate's subject Distinguished Name (DN). The Subject parameter can also take an MD5, SHA-1, or SHA-256 thumbprint of the certificate to load in a "Thumbprint=value" format.

public Certificate(int storeType, byte[] store, String storePassword, byte[] encoded);

StoreType identifies the type of certificate store to use. See for descriptions of the different certificate stores. Store is a byte array containing the certificate data. StorePassword is the password used to protect the store.

After the store has been successfully opened, the class will load Encoded as an X.509 certificate and search the opened store for a corresponding private key.

FTPConnection Type

This is a client currently connected to the server.

Remarks

This type represents a client connection to the server.

See the Connections property for more information.

The following fields are available:

Fields

ClientAddress
String (read-only)

Default Value: ""

This field contains the IP address of the connected client.

This field is read only.

ClientPort
int (read-only)

Default Value: 0

This field contains the port of the connected client.

This field is read only.

CurrentDirectory
String (read-only)

Default Value: ""

This field contains the current directory of the connected client.

This field is read only.

CurrentFileName
String (read-only)

Default Value: ""

This field contains the current filename of the connected client.

This field is read only.

FileData
String

Default Value: ""

This field contains the file data when not using a local file or stream. This field may hold file data to be sent in response to a download request, or it may be populated with file data received from the client when uploading.

From within the FileDownload event set FileData to the content of the file to be sent back.

From within the FileUpload event set the LocalFile parameter to an empty string to indicate that the file should be saved in the FileData field instead of written to disk. When EndTransfer fires the FileData field will contain the upload file data.

FileDataB
byte[]

Default Value: ""

This field contains the file data when not using a local file or stream. This field may hold file data to be sent in response to a download request, or it may be populated with file data received from the client when uploading.

From within the FileDownload event set FileData to the content of the file to be sent back.

From within the FileUpload event set the LocalFile parameter to an empty string to indicate that the file should be saved in the FileData field instead of written to disk. When EndTransfer fires the FileData field will contain the upload file data.

Id
String (read-only)

Default Value: ""

This field contains the Id of the connected client.

This field is read only.

Idle
boolean (read-only)

Default Value: False

This field says whether or not the connected client is idle.

This field is read only.

LastCommand
String (read-only)

Default Value: ""

This field contains the last received FTP command for this connection.

This field is read only.

RootDir
String (read-only)

Default Value: ""

This field contains the local root directory of the connected client.

This field is read only.

Timeout
int (read-only)

Default Value: 0

This field contains the timeout period for the connected client.

This field is read only.

TransferMode
int (read-only)

Default Value: 0

This field includes the transfer mode (ASCII or binary). If the value is 0 (default), the initial server mode will be used. The valid options for the TransferMode property are as follows:

tmDefault (0) The initial mode of the FTP server is taken. No change.
tmASCII (1) Files are transferred in ASCII mode (sends a TYPE A command).
tmBinary (2) Files are transferred in binary mode (sends a TYPE I command).

UserName
String (read-only)

Default Value: ""

This field contains the username for the connected client.

This field is read only.

Constructors

public FTPConnection();

FTPUser Type

This is a user who is authorized to connect to the server.

Remarks

This type represents a user with which a client may log into the server. It contains the user's credentials, home directory, and permissions.

See the AddUser method and the Users property for more information.

The following fields are available:

Fields

ACL
int (read-only)

Default Value: 0xFFFF

This field contains the access policy for this user.

  • 0x0001: ACL_DIR_CREATE
  • 0x0002: ACL_DIR_REMOVE
  • 0x0100: ACL_FILE_UPLOAD
  • 0x0200: ACL_FILE_DELETE
  • 0x0400: ACL_FILE_RENAME
  • 0xFFFF: ACL_ALL

This field is read-only.

Connected
boolean (read-only)

Default Value: False

This field notes whether any connected sessions are present for this user.

This field is read-only.

HomeDir
String (read-only)

Default Value: ""

This field contains the HomeDir is the directory that will be the initial working directory for the user upon login. To use the same location as the RootDir, set it to an empty string or /. Otherwise, this value must be a virtual path relative to RootDir (or DefaultRootDir if applicable). Users may navigate up from their HomeDir as long as they do not navigate above their RootDir, which they are not able to leave. An example of the meanings of the two values follows:

RootDir HomeDir Full local home path
C:/FTPServer /Users/Me C:/FTPServer/Users/Me
.

This field is read-only.

Name
String (read-only)

Default Value: ""

This field contains the name for this user.

This field is read-only.

Password
String (read-only)

Default Value: ""

This field contains the password for this user.

This field is read-only.

RootDir
String (read-only)

Default Value: ""

This field contains the local root directory for this user.

This field is read-only.

Constructors

public FTPUser();
public FTPUser(String name, String password, String rootDir, String homeDir, int ACL);

Config Settings (FTPServer Class)

The class accepts one or more of the following configuration settings. Configuration settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the class, access to these internal properties is provided through the Config method.

FTPServer Config Settings

AllowActiveMode:   Whether to allow clients to connect in active mode.

This setting specifies whether active mode connections are allowed. If set to True, clients may connect in either active or passive mode. If set to False, and a client attempts to connect in active mode, an error is returned.

AllowCompression:   Whether to allow MODE Z compression.

This setting specifies whether MODE Z compression is allowed. If set to True (default), connected clients may optionally use MODE Z compression for data transfers. If set to False and the client requests MODE Z compression, an error is returned.

The default value is True.

ConnectionBacklog:   The maximum number of pending connections maintained by the TCP/IP subsystem.

This setting contains the maximum number of pending connections maintained by the TCP/IP subsystem. This value reflects the SOMAXCON option for the main listening socket. The default value for most systems is 5. This may be set to a larger value if the server is expected to receive a large number of connections, and queuing them is desirable.

DefaultConnectionTimeout:   The inactivity timeout applied to SSL and DI connections.

This setting specifies the inactivity (in seconds) to apply to incoming SSL and DI connections. When set to a positive value, if the other end is unresponsive for the specified number of seconds, the connection will time out. This is not applicable to the entire handshake, only to the inactivity of the connecting client during the handshake; if a response is expected and none is received within the timeout window, the default value is 0, and no connection specific timeout is applied.

NOTE: This is applicable only to incoming SSL and DI connections. This should be set only if there is a specific reason to do so.

DefaultDIInBufferSize:   The size in bytes of the incoming queue of the socket.

This is the size of an internal queue in the TCP/IP stack. You can increase or decrease its size depending on the amount of data that you will be receiving. Increasing the value of the DefaultDIInBufferSize setting can provide significant improvements in performance in some cases.

Some TCP/IP implementations do not support variable buffer sizes. If that is the case, when the class is activated, the DefaultDIInBufferSize reverts to its defined size. The same happens if you attempt to make it too large or too small.

DefaultDIOutBufferSize:   The size in bytes of the outgoing queue of the socket.

This is the size of an internal queue in the TCP/IP stack. You can increase or decrease its size depending on the amount of data that you will be sending. Increasing the value of the DefaultDIOutBufferSize setting can provide significant improvements in performance in some cases.

Some TCP/IP implementations do not support variable buffer sizes. If that is the case, when the class is activated the DefaultDIOutBufferSize reverts to its defined size. The same happens if you attempt to make it too large or too small.

IncludeFiletimeAge:   The age in days after which hours and minutes are not included in the timestamp in directory listings.

The datetime portion of the directory listing response may be returned in two formats. For recent files, the format includes the hour and minutes, but excludes the year. For older files, the format omits the hour and minutes, but includes the year. For instance:

Recent TimeApr 23 19:39
Older TimeApr 22 2021
This setting controls the age in days when filetimes are considered older. Any file more recent than the number of days set here will use the recent time format. Any files older than the number of days set here will use the older time format.

The default value is 30 days.

KeepAlive:   When True, KEEPALIVE packets are enabled (for long connections).

This property enables the SO_KEEPALIVE option on the incoming connections. This option prevents long connections from timing out in case of inactivity.

NOTE: System TCP/IP stack implementations are not required to support SO_KEEPALIVE.

This property is shared among incoming connections. When the property is set, the corresponding value is set for incoming connections as they are accepted. Existing connections are not modified.

Linger:   When set to True, connections are terminated gracefully.

This property controls how a connection is closed. The default is True.

In the case that Linger is True (default), the system will attempt to send pending data for a connection until the default IP timeout expires.

The default behavior might result in a long delay in closing the connection. Although the class returns control immediately, the system could hold system resources until all pending data are sent (even after your application closes).

Setting this property to False forces an immediate disconnection. If you know that the other side has received all the data you sent (e.g., by a client acknowledgment), setting this property to False might be the appropriate course of action.

PassiveModeAddress:   Public IP address to be communicated to the client for Passive mode use.

The public IP address of the server that the client will connect to when in Passive mode.

PassiveModePortRange:   Range of ports to use in Passive mode connections.

The range of ports the server should use for opening data channels when in Passive mode. This string should be formatted as two integers representing valid ports separated by a dash. For example, 2222-3333.

WelcomeMessage:   The welcome message displayed to connecting clients.

This setting specifies the initial message that is sent to the connecting client. This may be set to indicate the type or version of the server, or communicate any other information as desired. Multiline values are supported. The default value is IPWorks! FTPServer 2020.

TCPServer Config Settings

AllowedClients:   A comma-separated list of host names or IP addresses that can access the class.

This configuration setting defines a comma-separated list of host names or IPv4 addresses that may access the class. The wildcard character "*" is supported. The default value is "*" and all connections are accepted.

When a client connects, the client's address is checked against the list defined here. If there is no match, the ConnectionRequest event fires with an Accept value set to false. If no action is taken within the ConnectionRequest event, the client will be disconnected.

BindExclusively:   Whether or not the class considers a local port reserved for exclusive use.

If this is true (default), the class will bind to the local port with the ExclusiveAddressUse option set, meaning that nothing else can bind to the same port. Also the class will not be able to bind to local ports that are already in use by some other instance, and attempts to do so will result in failure.

BlockedClients:   A comma-separated list of host names or IP addresses that cannot access the class.

This configuration setting defines a comma-separated list of host names or IPv4 addresses that cannot access the class.The default value is "" and all connections are accepted.

When a client connects, the client's address is checked against the list defined here. If there is a match, the ConnectionRequest event fires with an Accept value set to false. If no action is taken within the ConnectionRequest event, the client will not be connected.

CloseStreamAfterTransfer:   If true, the class will close the upload or download stream after the transfer.

This configuration setting determines whether the input or output stream is closed after the transfer completes. When set to True (default), all streams will be closed after a transfer is completed. To keep streams open after the transfer of data, set this to False. The default value is True.

DefaultConnectionTimeout:   The inactivity timeout applied to the SSL handshake.

This configuration setting specifies the inactivity (in seconds) to apply to incoming Secure Sockets Layer (SSL) connections. When set to a positive value, if the other end is unresponsive for the specified number of seconds, the connection will timeout. This is not applicable to the entire handshake. It is applicable only to the inactivity of the connecting client during the handshake if a response is expected and none is received within the timeout window. The default value is 0, and no connection-specific timeout is applied.

NOTE: This is applicable only to incoming SSL connections. This should be set only if there is a specific reason to do so.

InBufferSize:   The size in bytes of the incoming queue of the socket.

This is the size of an internal queue in the Transmission Control Protocol (TCP)/IP stack. You can increase or decrease its size depending on the amount of data that you will be receiving. Increasing the value of the InBufferSize setting can provide significant improvements in performance in some cases.

Some TCP/IP implementations do not support variable buffer sizes. If that is the case, when the class is activated, the InBufferSize reverts to its defined size. The same thing will happen if you attempt to make it too large or too small.

InBufferSize is shared among incoming connections. When the setting is set, the corresponding value is set for incoming connections as they are accepted. Existing connections are not modified.

KeepAliveInterval:   The retry interval, in milliseconds, to be used when a TCP keep-alive packet is sent and no response is received.

A TCP keep-alive packet will be sent after a period of inactivity, as defined by KeepAliveTime. If no acknowledgment is received from the remote host, the keep-alive packet will be sent again. This setting specifies the interval at which the successive keep-alive packets are sent in milliseconds. If this value is not specified here, the system default is 1 second. This setting is applicable to all connections.

NOTE: This value is not applicable in macOS.

KeepAliveTime:   The inactivity time in milliseconds before a TCP keep-alive packet is sent.

By default, the operating system will determine the time a connection is idle before a TCP keep-alive packet is sent. If this value is not specified here, the system default is 2 hours. In many cases, a shorter interval is more useful. Set this value to the desired interval in milliseconds. This setting is applicable to all connections.

MaxConnections:   The maximum number of connections available.

This is the maximum number of connections available. This setting must be set before Listening is set to true, and once set, it can no longer be changed for the current instance of the class. The maximum value for this setting is 100,000 connections. Use this setting with caution. Extremely large values may affect performance.

OutBufferSize:   The size in bytes of the outgoing queue of the socket.

This is the size of an internal queue in the TCP/IP stack. You can increase or decrease its size depending on the amount of data that you will be sending. Increasing the value of the OutBufferSize setting can provide significant improvements in performance in some cases.

Some TCP/IP implementations do not support variable buffer sizes. If that is the case, when the class is activated the OutBufferSize reverts to its defined size. The same thing will happen if you attempt to make it too large or too small.

OutBufferSize is shared among incoming connections. When the setting is set, the corresponding value is set for incoming connections as they are accepted. Existing connections are not modified.

PreferredDHGroupBits:   Size of the Diffie-Hellman group, in bits.

This configuration setting specifies the key length used by the Diffie-Hellman key algorithm. The default value is 2048 (bits).

TcpNoDelay:   Whether or not to delay when sending packets.

When set to True, the socket will send all data that are ready to send at once. When set to False, the socket will send smaller buffered packets of data at small intervals. This is known as the Nagle algorithm.

By default, this configuration setting is set to False.

UseIPv6:   Whether to use IPv6.

When set to 0 (default), the class will use IPv4 exclusively. When set to 1, the class will use IPv6 exclusively. When set to 2, the class will listen for both IPv4 and IPv6 connections. If IPv6 is not available on the system, only IPv4 will be used. The default value is 0. Possible values are as follows:

0 IPv4 Only
1 IPv6 Only
2 IPv6 and IPv4

SSL Config Settings

LogSSLPackets:   Controls whether SSL packets are logged when using the internal security API.

When SSLProvider is set to Internal, this configuration setting controls whether Secure Sockets Layer (SSL) packets should be logged. By default, this configuration setting is False, as it is useful only for debugging purposes.

When enabled, SSL packet logs are output using the SSLStatus event, which will fire each time an SSL packet is sent or received.

Enabling this configuration setting has no effect if SSLProvider is set to Platform.

ReuseSSLSession:   Determines if the SSL session is reused.

If set to True, the class will reuse the context if and only if the following criteria are met:

  • The target host name is the same.
  • The system cache entry has not expired (default timeout is 10 hours).
  • The application process that calls the function is the same.
  • The logon session is the same.
  • The instance of the class is the same.

SSLCACerts:   A newline separated list of CA certificates to be included when performing an SSL handshake.

When SSLProvider is set to Internal, this configuration setting specifies one or more CA certificates to be included with the SSLCert property. Some servers or clients require the entire chain, including CA certificates, to be presented when performing SSL authentication. The value of this configuration setting is a newline-separated (CR/LF) list of certificates. For instance:

-----BEGIN CERTIFICATE-----
MIIEKzCCAxOgAwIBAgIRANTET4LIkxdH6P+CFIiHvTowDQYJKoZIhvcNAQELBQAw
... Intermediate Cert ...
eWHV5OW1K53o/atv59sOiW5K3crjFhsBOd5Q+cJJnU+SWinPKtANXMht+EDvYY2w
F0I1XhM+pKj7FjDr+XNj
-----END CERTIFICATE-----
\r \n
-----BEGIN CERTIFICATE-----
MIIEFjCCAv6gAwIBAgIQetu1SMxpnENAnnOz1P+PtTANBgkqhkiG9w0BAQUFADBp
... Root Cert ...
d8q23djXZbVYiIfE9ebr4g3152BlVCHZ2GyPdjhIuLeH21VbT/dyEHHA
-----END CERTIFICATE-----

SSLCheckCRL:   Whether to check the Certificate Revocation List for the server certificate.

This configuration setting specifies whether the class will check the Certificate Revocation List (CRL) specified by the server certificate. If set to 1 or 2, the class will first obtain the list of CRL URLs from the server certificate's CRL distribution points extension. The class will then make HTTP requests to each CRL endpoint to check the validity of the server's certificate. If the certificate has been revoked or any other issues are found during validation the class throws an exception.

When set to 0 (default), the CRL check will not be performed by the class. When set to 1, it will attempt to perform the CRL check, but it will continue without an error if the server's certificate does not support CRL. When set to 2, it will perform the CRL check and will throw an error if CRL is not supported.

This configuration setting is supported only in the Java, C#, and C++ editions. In the C++ edition, it is supported only on Windows operating systems.

SSLCheckOCSP:   Whether to use OCSP to check the status of the server certificate.

This configuration setting specifies whether the class will use OCSP to check the validity of the server certificate. If set to 1 or 2, the class will first obtain the Online Certificate Status Protocol (OCSP) URL from the server certificate's OCSP extension. The class will then locate the issuing certificate and make an HTTP request to the OCSP endpoint to check the validity of the server's certificate. If the certificate has been revoked or any other issues are found during validation, the class throws an exception.

When set to 0 (default), the class will not perform an OCSP check. When set to 1, it will attempt to perform the OCSP check, but it will continue without an error if the server's certificate does not support OCSP. When set to 2, it will perform the OCSP check and will throw an error if OCSP is not supported.

This configuration setting is supported only in the Java, C#, and C++ editions. In the C++ edition, it is supported only on Windows operating systems.

SSLCipherStrength:   The minimum cipher strength used for bulk encryption.

This minimum cipher strength is largely dependent on the security modules installed on the system. If the cipher strength specified is not supported, an error will be returned when connections are initiated.

NOTE: This configuration setting contains the minimum cipher strength requested from the security library. The actual cipher strength used for the connection is shown by the SSLStatus event.

Use this configuration setting with caution. Requesting a lower cipher strength than necessary could potentially cause serious security vulnerabilities in your application.

When the provider is OpenSSL, SSLCipherStrength is currently not supported. This functionality is instead made available through the OpenSSLCipherList configuration setting.

SSLClientCACerts:   A newline separated list of CA certificates to use during SSL client certificate validation.

This configuration setting is only applicable to server classes (e.g., TCPServer) see SSLServerCACerts for client classes (e.g., TCPClient). This setting can be used to optionally specify one or more CA certificates to be used when verifying the client certificate that is presented by the client during the SSL handshake when SSLAuthenticateClients is enabled. When verifying the client's certificate, the certificates trusted by the system will be used as part of the verification process. If the client's CA certificates are not installed to the trusted system store, they may be specified here so they are included when performing the verification process. This configuration setting should be set only if the client's CA certificates are not already trusted on the system and cannot be installed to the trusted system store.

The value of this configuration setting is a newline-separated (CR/LF) list of certificates. For instance:

-----BEGIN CERTIFICATE-----
MIIEKzCCAxOgAwIBAgIRANTET4LIkxdH6P+CFIiHvTowDQYJKoZIhvcNAQELBQAw
... Intermediate Cert ...
eWHV5OW1K53o/atv59sOiW5K3crjFhsBOd5Q+cJJnU+SWinPKtANXMht+EDvYY2w
F0I1XhM+pKj7FjDr+XNj
-----END CERTIFICATE-----
\r \n
-----BEGIN CERTIFICATE-----
MIIEFjCCAv6gAwIBAgIQetu1SMxpnENAnnOz1P+PtTANBgkqhkiG9w0BAQUFADBp
... Root Cert ...
d8q23djXZbVYiIfE9ebr4g3152BlVCHZ2GyPdjhIuLeH21VbT/dyEHHA
-----END CERTIFICATE-----

SSLContextProtocol:   The protocol used when getting an SSLContext instance.

Possible values are SSL, SSLv2, SSLv3, TLS, and TLSv1. Use this configuration setting only in case your security provider does not support TLS. This is the parameter "protocol" inside the SSLContext.getInstance(protocol) call.

SSLEnabledCipherSuites:   The cipher suite to be used in an SSL negotiation.

This configuration setting enables the cipher suites to be used in SSL negotiation.

By default, the enabled cipher suites will include all available ciphers ("*").

The special value "*" means that the class will pick all of the supported cipher suites. If SSLEnabledCipherSuites is set to any other value, only the specified cipher suites will be considered.

Multiple cipher suites are separated by semicolons.

NOTE: This value must be set after SSLProvider is set.

Example values: obj.config("SSLEnabledCipherSuites=*"); obj.config("SSLEnabledCipherSuites=SSL_RSA_WITH_RC4_128_SHA"); obj.config("SSLEnabledCipherSuites=SSL_RSA_WITH_RC4_128_SHA; SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA"); Possible values when SSLProvider is set to Platform include the following:

  • SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA
  • SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA
  • SSL_RSA_WITH_RC4_128_SHA
  • SSL_RSA_WITH_DES_CBC_SHA
  • SSL_RSA_EXPORT_WITH_DES40_CBC_SHA
  • SSL_DH_anon_WITH_DES_CBC_SHA
  • SSL_RSA_EXPORT_WITH_RC4_40_MD5
  • SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA
  • SSL_DH_anon_EXPORT_WITH_RC4_40_MD5
  • SSL_DHE_DSS_WITH_DES_CBC_SHA
  • SSL_RSA_WITH_NULL_MD5
  • SSL_DH_anon_WITH_3DES_EDE_CBC_SHA
  • SSL_DHE_RSA_WITH_DES_CBC_SHA
  • SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA
  • SSL_RSA_WITH_NULL_SHA
  • SSL_DH_anon_WITH_RC4_128_MD5
  • SSL_RSA_WITH_RC4_128_MD5
  • SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA
  • SSL_RSA_WITH_3DES_EDE_CBC_SHA
  • TLS_ECDH_ECDSA_WITH_NULL_SHA
  • TLS_DH_anon_WITH_AES_128_CBC_SHA256 (Not Recommended)
  • TLS_ECDH_anon_WITH_RC4_128_SHA
  • TLS_DH_anon_WITH_AES_128_CBC_SHA (Not Recommended)
  • TLS_DHE_RSA_WITH_AES_128_CBC_SHA
  • TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA
  • TLS_KRB5_WITH_3DES_EDE_CBC_SHA
  • TLS_DHE_DSS_WITH_AES_128_CBC_SHA256
  • TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA
  • TLS_DHE_RSA_WITH_AES_128_CBC_SHA256
  • TLS_KRB5_EXPORT_WITH_RC4_40_SHA
  • TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256
  • TLS_ECDHE_RSA_WITH_RC4_128_SHA
  • TLS_ECDH_ECDSA_WITH_RC4_128_SHA
  • TLS_ECDH_anon_WITH_NULL_SHA
  • TLS_ECDHE_ECDSA_WITH_RC4_128_SHA
  • TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
  • TLS_RSA_WITH_NULL_SHA256
  • TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA
  • TLS_KRB5_WITH_RC4_128_MD5
  • TLS_ECDHE_ECDSA_WITH_NULL_SHA
  • TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA
  • TLS_ECDH_RSA_WITH_RC4_128_SHA
  • TLS_EMPTY_RENEGOTIATION_INFO_SCSV
  • TLS_KRB5_WITH_3DES_EDE_CBC_MD5
  • TLS_KRB5_WITH_RC4_128_SHA
  • TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA
  • TLS_ECDH_RSA_WITH_NULL_SHA
  • TLS_ECDH_RSA_WITH_AES_128_CBC_SHA
  • TLS_KRB5_WITH_DES_CBC_MD5
  • TLS_KRB5_EXPORT_WITH_RC4_40_MD5
  • TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5
  • TLS_ECDH_anon_WITH_AES_128_CBC_SHA
  • TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
  • TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
  • TLS_KRB5_WITH_DES_CBC_SHA
  • TLS_RSA_WITH_AES_128_CBC_SHA
  • TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA
  • TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
  • TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256
  • TLS_ECDHE_RSA_WITH_NULL_SHA
  • TLS_RSA_WITH_AES_128_CBC_SHA256
  • TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
  • TLS_DHE_DSS_WITH_AES_128_CBC_SHA

Possible values when SSLProvider is set to Internal include the following:

  • TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
  • TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
  • TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
  • TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
  • TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384
  • TLS_RSA_WITH_AES_256_GCM_SHA384
  • TLS_RSA_WITH_AES_128_GCM_SHA256
  • TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256
  • TLS_DHE_DSS_WITH_AES_256_GCM_SHA384
  • TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
  • TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384
  • TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256
  • TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
  • TLS_DHE_DSS_WITH_AES_128_GCM_SHA256
  • TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
  • TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
  • TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384
  • TLS_DHE_DSS_WITH_AES_256_CBC_SHA256
  • TLS_RSA_WITH_AES_256_CBC_SHA256
  • TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
  • TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384
  • TLS_DHE_RSA_WITH_AES_256_CBC_SHA256
  • TLS_DHE_RSA_WITH_AES_128_CBC_SHA256
  • TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
  • TLS_RSA_WITH_AES_128_CBC_SHA256
  • TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256
  • TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256
  • TLS_DHE_DSS_WITH_AES_128_CBC_SHA256
  • TLS_RSA_WITH_AES_256_CBC_SHA
  • TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
  • TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
  • TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA
  • TLS_DHE_RSA_WITH_AES_256_CBC_SHA
  • TLS_ECDH_RSA_WITH_AES_256_CBC_SHA
  • TLS_DHE_DSS_WITH_AES_256_CBC_SHA
  • TLS_RSA_WITH_AES_128_CBC_SHA
  • TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
  • TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
  • TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA
  • TLS_ECDH_RSA_WITH_AES_128_CBC_SHA
  • TLS_DHE_RSA_WITH_AES_128_CBC_SHA
  • TLS_DHE_DSS_WITH_AES_128_CBC_SHA
  • TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA
  • TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
  • TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA
  • TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA
  • TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA
  • TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA
  • TLS_RSA_WITH_3DES_EDE_CBC_SHA
  • TLS_RSA_WITH_DES_CBC_SHA
  • TLS_DHE_RSA_WITH_DES_CBC_SHA
  • TLS_DHE_DSS_WITH_DES_CBC_SHA
  • TLS_RSA_WITH_RC4_128_MD5
  • TLS_RSA_WITH_RC4_128_SHA

When TLS 1.3 is negotiated (see SSLEnabledProtocols), only the following cipher suites are supported:

  • TLS_AES_256_GCM_SHA384
  • TLS_CHACHA20_POLY1305_SHA256
  • TLS_AES_128_GCM_SHA256

SSLEnabledCipherSuites is used together with SSLCipherStrength.

SSLEnabledProtocols:   Used to enable/disable the supported security protocols.

This configuration setting is used to enable or disable the supported security protocols.

Not all supported protocols are enabled by default. The default value is 4032 for client classes, and 3072 for server classes. To specify a combination of enabled protocol versions set this config to the binary OR of one or more of the following values:

TLS1.312288 (Hex 3000)
TLS1.23072 (Hex C00) (Default - Client and Server)
TLS1.1768 (Hex 300) (Default - Client)
TLS1 192 (Hex C0) (Default - Client)
SSL3 48 (Hex 30)
SSL2 12 (Hex 0C)

Note that only TLS 1.2 is enabled for server classes that accept incoming connections. This adheres to industry standards to ensure a secure connection. Client classes enable TLS 1.0, TLS 1.1, and TLS 1.2 by default and will negotiate the highest mutually supported version when connecting to a server, which should be TLS 1.2 in most cases.

SSLEnabledProtocols: Transport Layer Security (TLS) 1.3 Notes:

By default when TLS 1.3 is enabled, the class will first try to use the platform TLS 1.3 implementation when the SSLProvider is set to Automatic for all editions. If the platform TLS 1.3 implementation is not available, the internal implementation will be used.

If set to 1 (Platform provider), please be aware of the following notes:

  • SSLEnabledCipherSuites and other similar SSL configuration settings are not supported.
  • If SSLEnabledProtocols includes both TLS 1.3 and TLS 1.2, these restrictions are still applicable even if TLS 1.2 is negotiated. Enabling TLS 1.3 with the platform provider changes the implementation used for all TLS versions.

In the Java edition, the class checks at runtime whether the security provider backing that default context supports the TLSv1.3 protocol.

The built-in SunJSSE provider supports TLS 1.3 starting with Java 11. On earlier Java versions, TLS 1.3 support depends on installing a third-party provider that supports it, and registering that provider ahead of the defaults.

If SSLProvider is set to Platform and the default security provider does not support TLSv1.3, an exception is thrown.

Example values: Security.insertProviderAt(new org.conscrypt.OpenSSLProvider(), 1); obj.setSSLProvider(HTTP.sslpPlatform); obj.config("SSLEnabledProtocols=12288");

SSLEnabledProtocols: SSL2 and SSL3 Notes:

SSL 2.0 and 3.0 are not supported by the class when the SSLProvider is set to internal. To use SSL 2.0 or SSL 3.0, the platform security API must have the protocols enabled and SSLProvider needs to be set to platform.

SSLEnableRenegotiation:   Whether the renegotiation_info SSL extension is supported.

This configuration setting specifies whether the renegotiation_info SSL extension will be used in the request when using the internal security API. This configuration setting is false by default, but it can be set to true to enable the extension.

This configuration setting is applicable only when SSLProvider is set to Internal.

SSLIncludeCertChain:   Whether the entire certificate chain is included in the SSLServerAuthentication event.

This configuration setting specifies whether the Encoded parameter of the SSLServerAuthentication event contains the full certificate chain. By default this value is False and only the leaf certificate will be present in the Encoded parameter of the SSLServerAuthentication event.

If set to True, all certificates returned by the server will be present in the Encoded parameter of the SSLServerAuthentication event. This includes the leaf certificate, any intermediate certificate, and the root certificate.

Note: When SSLProvider is set to Internal this value is automatically set to true. This is needed for proper validation when using the internal provider.

SSLKeyLogFile:   The location of a file where per-session secrets are written for debugging purposes.

This configuration setting optionally specifies the full path to a file on disk where per-session secrets are stored for debugging purposes.

When set, the class will save the session secrets in the same format as the SSLKEYLOGFILE environment variable functionality used by most major browsers and tools, such as Chrome, Firefox, and cURL. This file can then be used in tools such as Wireshark to decrypt TLS traffic for debugging purposes. When writing to this file, the class will only append, it will not overwrite previous values.

NOTE: This configuration setting is applicable only when SSLProvider is set to Internal.

SSLNegotiatedCipher:   Returns the negotiated cipher suite.

This configuration setting returns the cipher suite negotiated during the SSL handshake.

NOTE: For server classes (e.g., TCPServer), this is a per-connection configuration setting accessed by passing the ConnectionId. For example: server.Config("SSLNegotiatedCipher[connId]");

SSLNegotiatedCipherStrength:   Returns the negotiated cipher suite strength.

This configuration setting returns the strength of the cipher suite negotiated during the SSL handshake.

NOTE: For server classes (e.g., TCPServer), this is a per-connection configuration setting accessed by passing the ConnectionId. For example: server.Config("SSLNegotiatedCipherStrength[connId]");

SSLNegotiatedCipherSuite:   Returns the negotiated cipher suite.

This configuration setting returns the cipher suite negotiated during the SSL handshake represented as a single string.

NOTE: For server classes (e.g., TCPServer), this is a per-connection configuration setting accessed by passing the ConnectionId. For example: server.Config("SSLNegotiatedCipherSuite[connId]");

SSLNegotiatedKeyExchange:   Returns the negotiated key exchange algorithm.

This configuration setting returns the key exchange algorithm negotiated during the SSL handshake.

NOTE: For server classes (e.g., TCPServer), this is a per-connection configuration setting accessed by passing the ConnectionId. For example: server.Config("SSLNegotiatedKeyExchange[connId]");

SSLNegotiatedKeyExchangeStrength:   Returns the negotiated key exchange algorithm strength.

This configuration setting returns the strength of the key exchange algorithm negotiated during the SSL handshake.

NOTE: For server classes (e.g., TCPServer), this is a per-connection configuration setting accessed by passing the ConnectionId. For example: server.Config("SSLNegotiatedKeyExchangeStrength[connId]");

SSLNegotiatedVersion:   Returns the negotiated protocol version.

This configuration setting returns the protocol version negotiated during the SSL handshake.

NOTE: For server classes (e.g., TCPServer), this is a per-connection configuration setting accessed by passing the ConnectionId. For example: server.Config("SSLNegotiatedVersion[connId]");

SSLServerCACerts:   A newline separated list of CA certificates to use during SSL server certificate validation.

This configuration setting is only used by client classes (e.g., TCPClient) see SSLClientCACerts for server classes (e.g., TCPServer). This configuration setting can be used to optionally specify one or more CA certificates to be used when connecting to the server and verifying the server certificate. When verifying the server's certificate, the certificates trusted by the system will be used as part of the verification process. If the server's CA certificates are not installed to the trusted system store, they may be specified here so they are included when performing the verification process. This configuration setting should be set only if the server's CA certificates are not already trusted on the system and cannot be installed to the trusted system store.

The value of this configuration setting is a newline-separated (CR/LF) list of certificates. For instance:

-----BEGIN CERTIFICATE-----
MIIEKzCCAxOgAwIBAgIRANTET4LIkxdH6P+CFIiHvTowDQYJKoZIhvcNAQELBQAw
... Intermediate Cert...
eWHV5OW1K53o/atv59sOiW5K3crjFhsBOd5Q+cJJnU+SWinPKtANXMht+EDvYY2w
F0I1XhM+pKj7FjDr+XNj
-----END CERTIFICATE-----
\r \n
-----BEGIN CERTIFICATE-----
MIIEFjCCAv6gAwIBAgIQetu1SMxpnENAnnOz1P+PtTANBgkqhkiG9w0BAQUFADBp
... Root Cert...
d8q23djXZbVYiIfE9ebr4g3152BlVCHZ2GyPdjhIuLeH21VbT/dyEHHA
-----END CERTIFICATE-----

SSLTrustManagerFactoryAlgorithm:   The algorithm to be used to create a TrustManager through TrustManagerFactory.

Possible values include SunX509. This is the parameter "algorithm" inside the TrustManagerFactory.getInstance(algorithm) call.

TLS12SignatureAlgorithms:   Defines the allowed TLS 1.2 signature algorithms when SSLProvider is set to Internal.

This configuration setting specifies the allowed server certificate signature algorithms when SSLProvider is set to Internal and SSLEnabledProtocols is set to allow TLS 1.2.

When specified the class will verify that the server certificate signature algorithm is among the values specified in this configuration setting. If the server certificate signature algorithm is unsupported, the class throws an exception.

The format of this value is a comma-separated list of hash-signature combinations. For instance: component.SSLProvider = TCPClientSSLProviders.sslpInternal; component.Config("SSLEnabledProtocols=3072"); //TLS 1.2 component.Config("TLS12SignatureAlgorithms=sha256-rsa,sha256-dsa,sha1-rsa,sha1-dsa"); The default value for this configuration setting is sha512-ecdsa,sha512-rsa,sha512-dsa,sha384-ecdsa,sha384-rsa,sha384-dsa,sha256-ecdsa,sha256-rsa,sha256-dsa,sha224-ecdsa,sha224-rsa,sha224-dsa,sha1-ecdsa,sha1-rsa,sha1-dsa.

To not restrict the server's certificate signature algorithm, specify an empty string as the value for this configuration setting, which will cause the signature_algorithms TLS 1.2 extension to not be sent.

TLS12SupportedGroups:   The supported groups for ECC.

This configuration setting specifies a comma-separated list of named groups used in TLS 1.2 for ECC.

The default value is ecdhe_secp256r1,ecdhe_secp384r1,ecdhe_secp521r1.

When using TLS 1.2 and SSLProvider is set to Internal, the values refer to the supported groups for ECC. The following values are supported:

  • "ecdhe_secp256r1" (default)
  • "ecdhe_secp384r1" (default)
  • "ecdhe_secp521r1" (default)

TLS13KeyShareGroups:   The groups for which to pregenerate key shares.

This configuration setting specifies a comma-separated list of named groups used in TLS 1.3 for key exchange. The groups specified here will have key share data pregenerated locally before establishing a connection. This can prevent an additional roundtrip during the handshake if the group is supported by the server.

The default value is set to balance common supported groups and the computational resources required to generate key shares. As a result, only some groups are included by default in this configuration setting.

NOTE: All supported groups can always be used during the handshake even if not listed here, but if a group is used that is not present in this list, it will incur an additional roundtrip and time to generate the key share for that group.

In most cases, this configuration setting does not need to be modified. This should be modified only if there is a specific reason to do so.

The default value is ecdhe_x25519,ecdhe_secp256r1,ecdhe_secp384r1,ffdhe_2048,ffdhe_3072

The values are ordered from most preferred to least preferred. The following values are supported:

  • "ecdhe_x25519" (default)
  • "ecdhe_x448"
  • "ecdhe_secp256r1" (default)
  • "ecdhe_secp384r1" (default)
  • "ecdhe_secp521r1"
  • "ffdhe_2048" (default)
  • "ffdhe_3072" (default)
  • "ffdhe_4096"
  • "ffdhe_6144"
  • "ffdhe_8192"

TLS13SignatureAlgorithms:   The allowed certificate signature algorithms.

This configuration setting holds a comma-separated list of allowed signature algorithms. Possible values include the following:

  • "ed25519" (default)
  • "ed448" (default)
  • "ecdsa_secp256r1_sha256" (default)
  • "ecdsa_secp384r1_sha384" (default)
  • "ecdsa_secp521r1_sha512" (default)
  • "rsa_pkcs1_sha256" (default)
  • "rsa_pkcs1_sha384" (default)
  • "rsa_pkcs1_sha512" (default)
  • "rsa_pss_sha256" (default)
  • "rsa_pss_sha384" (default)
  • "rsa_pss_sha512" (default)
The default value is rsa_pss_sha256,rsa_pss_sha384,rsa_pss_sha512,rsa_pkcs1_sha256,rsa_pkcs1_sha384,rsa_pkcs1_sha512,ecdsa_secp256r1_sha256,ecdsa_secp384r1_sha384,ecdsa_secp521r1_sha512,ed25519,ed448. This configuration setting is applicable only when SSLEnabledProtocols includes TLS 1.3.
TLS13SupportedGroups:   The supported groups for (EC)DHE key exchange.

This configuration setting specifies a comma-separated list of named groups used in TLS 1.3 for key exchange. This configuration setting should be modified only if there is a specific reason to do so.

The default value is ecdhe_x25519,ecdhe_x448,ecdhe_secp256r1,ecdhe_secp384r1,ecdhe_secp521r1,ffdhe_2048,ffdhe_3072,ffdhe_4096,ffdhe_6144,ffdhe_8192,mlkem_512,mlkem_768,mlkem_1024,x25519_mlkem_768,secp256r1_mlkem_768

The values are ordered from most preferred to least preferred. The following values are supported:

  • "ecdhe_x25519" (default)
  • "ecdhe_x448" (default)
  • "ecdhe_secp256r1" (default)
  • "ecdhe_secp384r1" (default)
  • "ecdhe_secp521r1" (default)
  • "ffdhe_2048" (default)
  • "ffdhe_3072" (default)
  • "ffdhe_4096" (default)
  • "ffdhe_6144" (default)
  • "ffdhe_8192" (default)
  • "mlkem_512" (default)
  • "mlkem_768" (default)
  • "mlkem_1024" (default)
  • "x25519_mlkem_768" (default)
  • "secp256r1_mlkem_768" (default)

Post-quantum algorithms (mlkem_512,mlkem_768,mlkem_1024,x25519_mlkem_768,secp256r1_mlkem_768) in our classes rely on the operating system's underlying cryptographic primitives. The following platforms are currently supported:

  • Windows Server 2025
  • Windows 11 24H2
  • Windows 11 25H2

Trappable Errors (FTPServer Class)

FTPServer Errors

1201   

TCPServer Errors

100   You cannot change the RemotePort at this time. A connection is in progress.
101   You cannot change the RemoteHost at this time. A connection is in progress.
102   The RemoteHost address is invalid (0.0.0.0).
104   TCPServer is already listening.
106   Cannot change LocalPort when TCPServer is listening.
107   Cannot change LocalHost when TCPServer is listening.
108   Cannot change MaxConnections when TCPServer is listening.
112   You cannot change MaxLineLength at this time. A connection is in progress.
116   RemotePort cannot be zero. Please specify a valid service port number.
126   Invalid ConnectionId.
135   Operation would block.

TCP/IP Errors

10004   [10004] Interrupted system call.
10009   [10009] Bad file number.
10013   [10013] Access denied.
10014   [10014] Bad address.
10022   [10022] Invalid argument.
10024   [10024] Too many open files.
10035   [10035] Operation would block.
10036   [10036] Operation now in progress.
10037   [10037] Operation already in progress.
10038   [10038] Socket operation on nonsocket.
10039   [10039] Destination address required.
10040   [10040] Message is too long.
10041   [10041] Protocol wrong type for socket.
10042   [10042] Bad protocol option.
10043   [10043] Protocol is not supported.
10044   [10044] Socket type is not supported.
10045   [10045] Operation is not supported on socket.
10046   [10046] Protocol family is not supported.
10047   [10047] Address family is not supported by protocol family.
10048   [10048] Address already in use.
10049   [10049] Cannot assign requested address.
10050   [10050] Network is down.
10051   [10051] Network is unreachable.
10052   [10052] Net dropped connection or reset.
10053   [10053] Software caused connection abort.
10054   [10054] Connection reset by peer.
10055   [10055] No buffer space available.
10056   [10056] Socket is already connected.
10057   [10057] Socket is not connected.
10058   [10058] Cannot send after socket shutdown.
10059   [10059] Too many references, cannot splice.
10060   [10060] Connection timed out.
10061   [10061] Connection refused.
10062   [10062] Too many levels of symbolic links.
10063   [10063] File name is too long.
10064   [10064] Host is down.
10065   [10065] No route to host.
10066   [10066] Directory is not empty
10067   [10067] Too many processes.
10068   [10068] Too many users.
10069   [10069] Disc Quota Exceeded.
10070   [10070] Stale NFS file handle.
10071   [10071] Too many levels of remote in path.
10091   [10091] Network subsystem is unavailable.
10092   [10092] WINSOCK DLL Version out of range.
10093   [10093] Winsock is not loaded yet.
11001   [11001] Host not found.
11002   [11002] Nonauthoritative 'Host not found' (try again or check DNS setup).
11003   [11003] Nonrecoverable errors: FORMERR, REFUSED, NOTIMP.
11004   [11004] Valid name, no data record (check DNS setup).