edtFTPnet/PRO - Secure FTP component for .NET | Free Trial | Pricing
[SFTP/FTPS] Method by which the server's certificate or public key is validated.

Namespace: EnterpriseDT.Net.Ftp
Assembly: edtFTPnetPRO (in edtFTPnetPRO.dll) Version: 8.0.0.20

Syntax

C#
public SecureFTPServerValidationType ServerValidation { get; set; }
Visual Basic
Public Property ServerValidation As SecureFTPServerValidationType
	Get
	Set
Visual C++
public:
property SecureFTPServerValidationType ServerValidation {
	SecureFTPServerValidationType get ();
	void set (SecureFTPServerValidationType value);
}

Remarks

The default for both SFTP and FTPS is Automatic.

SFTP: SFTP servers are validated by means of their public key. Typically, the server's public key is stored in either a file containing that single key, or in a file often called known_hosts which can contain a number of public keys for different servers. When the client connects to the server, the server's public key is returned and compared with the available public keys stored in the client. Known-host files may be loaded by setting the KnownHosts.KnownHostsFile property. Individual public keys may be loaded using the KnownHosts.AddKnownHost method.

Examples

The following example illustrates the loading of server public keys using a known-hosts file:
 Copy imageCopy
              SecureFTPConnection ftp = new SecureFTPConnection();
              ftp.Protocol = FileTransferProtocol.SFTP;
              ftp.ServerAddress = "my-server-name";
              ftp.UserName = "my-username";
              ftp.Password = "my-password";
              ftp.AuthenticationMethod = AuthenticationType.Password;
              ftp.ServerValidation = SecureFTPServerValidationType.Automatic;
              ftp.KnownHosts.KnownHostsFile = "my-knownhosts-file";
              ftp.Connect();
              ftp.Close();
            

Examples

The following example illustrates the loading of a server's public key from a public key file:
 Copy imageCopy
              SecureFTPConnection ftp = new SecureFTPConnection();
              ftp.Protocol = FileTransferProtocol.SFTP;
              ftp.ServerAddress = "my-server-name";
              ftp.UserName = "my-username";
              ftp.Password = "my-password";
              ftp.AuthenticationMethod = AuthenticationType.Password;
              ftp.ServerValidation = SecureFTPServerValidationType.Automatic;
              ftp.KnownHosts.AddKnownHost("servers-public-key-file");
              ftp.Connect();
              ftp.Close();
            

FTPS: When an SSL/TLS connection is being negotiated, the FTPS server will present an SSL certificate to the client. SecureFTPServerValidationTypes are used to control what the client does with this certificate. If server validation is used then the server's certificate will be validated against those installed on the machine. Please refer to the class description for more information.

Examples

The following example illustrates the establishment of an explicit FTPS connection using automatic server validation
 Copy imageCopy
              SecureFTPConnection ftp = new SecureFTPConnection();
              ftp.Protocol = FileTransferProtocol.FTPSExplicit;
              ftp.ServerAddress = "my-server-name";
              ftp.UserName = "my-username";
              ftp.Password = "my-password";
              ftp.ServerValidation = SecureFTPServerValidationType.Automatic;
              // the server's certificate must have been previously registered with
              // the operating system (see class description)
              ftp.Connect();
              ftp.Close();
            

See Also