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

This topic continues from How to use FTPS (with server validation - part A) and How to use FTPS (with server validation - part B).

Sometimes it may be desirable to ignore the CommonName (CN) of the server's certificate completely. A new instance of SSLFTPStandardValidator must be created and assigned, as shown below:

ftp.setCustomValidator(new SSLFTPStandardValidator(false));

Here, the SSLFTPStandardValidator's constructor is supplied with a flag indicating it should not attempt to match the CN of the server certificate with the hostname.

In this case the server's certificate is still validated against the loaded CA certificate, but its CommonName (CN) is ignored.