Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
5.2k views
in Java FTP by (220 points)
I am getting the following error

[error]
com.enterprisedt.net.puretls.SSLHandshakeFailedException: java.net.SocketException: Connection reset
at com.enterprisedt.net.puretls.SSLConn.handshake(SSLConn.java:155)
at com.enterprisedt.net.puretls.SSLSocket.internalSocket(SSLSocket.java:296)
at com.enterprisedt.net.puretls.SSLSocket.<init>(SSLSocket.java:121)
at com.enterprisedt.net.ftp.ssl.B.<init>(Unknown Source)
at com.enterprisedt.net.ftp.ssl.SSLFTPClient.connect(Unknown Source)
at Demo.main(Demo.java:61)
[/error]

Here is my code

    try {
      // create client
      log.info("Creating FTPS (explicit) client");
      ftp =
        new SSLFTPClient(
          host,22);

      // turn off server validation
      log.info("Turning off server validation");
      ftp.setValidateServer(false);

      // connect to the server
      log.info("Connecting to server " + host);
      ftp.connect();



The error is happening on ftp.connect()

2 Answers

0 votes
by (51.6k points)
Hi

There are a couple of strange things about this.

Firstly, I notice that you're connecting to port 22. Port 22 is usually used for SSH and SFTP. Your code is using the FTPS client, which implements the FTPS protocol normally run on port 21 (like standard FTP). SFTP and FTPS are completely different protocols and are incompatible. If the server is an SFTP server, then you'll need to use the com.enterprisedt.net.ftp.ssh.SSHFTPClient class. Having said that, it would be possible to set up FTPS to run on port 22, but it would be against convention.

Secondly, if the server is indeed an FTPS server then the code that you have sent is not consistent with the stack-trace you provided. This is because the connect() method should only attempt an SSL handshake if the IMPLICIT_FTPS flag is not included in the constructor. Are you sure that the code that you quoted was the code that resulted in that stack-trace?

- Hans (EDT Support)
0 votes
by (220 points)
It worked when I changed to SSHFTPClient. Thanks for your help

Categories

...