After establishing FTP TLS explicit connection on port 21 I've want to upload a file to that server. After calling ftps.storeFile(fileName, inputStream);
I've received this exception
javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
.
The file itself gets created on the FTP server but it's empty containign 0 bytes.
I'm running my JVM on 1.8.172 so it's not the case of Java 7 problems.
By connecting to the FTP server via FileZilla I've noticed that this server uses TLS 1.2 so I've added that protocol to the JVM arguments AND session enabled protocols. Still the same result.
FTPSClient ftps = new FTPSClient(false);
ftps.connect(host, port) //The port is 21
ftps.login(user, password);
ftps.execPROT("P"); //Turning file transfer encryption which is required by the server
ftps.setEnabledProtocols(new String[] {"TLSv1", "TLSv1.1", "TLSv1.2"});
ftps.changeWorkingDirectory(ftpCatalog); //Catalog gets changed succesfully
ftps.setFileTransferMode(FTP.BINARY_FILE_TYPE);
ftps.setFileType(FTP.BINARY_FILE_TYPE);
ftps.setCharset(StandardCharsets.UTF_8);
FileInputStream inputStream = new FileInputStream(filePath);
ftps.storeFile(fileName, inputStream)// <--- Here the exception's gets thrown
UPDATE: I've managed to get the logs directly from the FTP server in which was
450 TLS session of data connection has not resumed or the session does not match the control connection
Topic closed since, it's now a duplicate. Answer is given here: How to connect to FTPS server with data connection using same TLS session?