How to use FTPS (with server validation - part A)
  

The topic How to use FTPS (introduction) describes the FTPS features of SecureFTPConnection.  This topic demonstrates the use of FTPS with server validation in the case where the server certificate's CommonName (CN) is the same as its address.


IMPORTANT: An FTPS compatible FTP server is required for this example.  There are free FTPS-compatible servers available on Windows and *NIX platforms.


As in FTPS without server validation, the Protocol and ServerValidation properties must be set:

ftpConnection.Protocol = FileTransferProtocol.FTPSExplicit;
ftpConnection.ServerValidation = SecureFTPServerValidationType.Automatic;


Setting ServerValidation to Automatic instructs SecureFTPConnection to match the certificate that the server presents against those in the Windows Certificate Store.  This means that either of the following must be true:

1.   the server certificate has been issued by a Certificate Authority, such as VeriSign or Thawte, whose certificate is in the Windows Certificate store; OR

2.         the server's certificate itself is in the Certificate Store.

In the first case no manipulation of the Windows Certificate store is necessary.  In the latter it is necessary to install the server certificate on the machine on which SecureFTPConnection is being used.  In order to make this simpler, edtFTPnet/PRO provides both design-time and runtime tools for managing certificates.  For more information of these tools please refer to the topic Certificate Manager.

The Certificate Manager may be presented at runtime using the SSLFTPCertificate.ShowCertificateManager method:

SSLFTPCertificate.ShowCertificateManager();


This only needs to be done once since the certificate will remain in the store until it is removed.

Once the server certificate or that of the Certificate Authority that issued it is in the Windows certificate store, the Connect() may simply be called to establish a secure connection:

ftpConnection.Connect();


While the secure connection is being established the CommonName (CN) of the server certificate is checked. If this check fails, the connection will fail. Please refer to How to use FTPS (with server validation - part B) and How to use FTPS (with server validation - part C) for more details on this issue.