SecureFTPConnectionServerValidation Property |
Namespace: EnterpriseDT.Net.Ftp
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.
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();
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.
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();