Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
5.1k views
in Java FTP by (160 points)
E-mail support request:

My company has been using edtFTPj for some time and is in the process of upgrading to edtFTPj/SSL. As a first step, I'd like to simply replace edtFTPj's FTPClient class with edtFTPj/SSL's SSLFTPClient class, without actually using the new FTPS. How do I do that?

1 Answer

0 votes
by (51.6k points)
If your existing edtFTPj code is as follows:
FTPClient ftp = new FTPClient(address);

then you may replace it by the following:
SSLFTPClient ftp = new SSLFTPClient(address, flags);
ftp.loadRootCertificates(rootCertFileName);
ftp.connect();

and it should work exactly the same. For fully standard compliant FTPS servers, the flags argument may be set to 0. If you find that the client hangs then try using the DISABLE_SSL_CLOSURE flag. The rootCertFileName is the path to the root certificate file. This file should contain the server certificate (or that of the CA which issued it). It is recommended that you use server authentication, but if you're sure you don't need it (e.g. if you're not using the secure FTP feature) then you can do the following:
SSLFTPClient ftp = new SSLFTPClient(address, flags);
ftp.setValidateServer(false);
ftp.connect();

which will turn off server validation (it is on by default).

In either case, the client operates as a normal FTP client until you call the auth() method.

To summarize, you must first call either loadRootCertificates() or setValidateServer(), and then you must call the connect() method. Other than that everything should work exactly the same as the non-SSL client.

Categories

...