Как решить SSLHandshakeException, используя Java FTPSClient?

Я использовал клиент FTPS Java для подключения к моему локальному серверу FileZilla. Но мой код скинуть SSLHandshakeException, Как мне это сделать? Помоги мне.

 public void doSend(String url, String port, String user, String password, File file, String fileName) throws IOException {
    String remote = fileName;
    FTPSClient client = new FTPSClient();
    client.setAuthValue("TLS");
    client.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));
    client.setRemoteVerificationEnabled(false);

    InputStream input = new BufferedInputStream(new FileInputStream(file));
    InetAddress inetAddress = Inet4Address.getLocalHost();
    client.connect(inetAddress, Integer.parseInt(port));
    client.setTrustManager(TrustManagerUtils.getAcceptAllTrustManager());

    int reply;
    reply = client.getReplyCode();

    if (!FTPReply.isPositiveCompletion(reply))
    {
        client.disconnect();
        System.err.println("FTP server refused connection.");
        System.exit(1);
    }

    client.login(user, password);

    client.setBufferSize(1000);
    client.enterLocalPassiveMode();
    client.setFileType(FTP.BINARY_FILE_TYPE);
    client.execPBSZ(0);
    client.execPROT("P");
    client.enterLocalPassiveMode();
    client.storeFile(remote, input);   //it cause exception
    client.logout();
}

Что проблема? Ниже мой журнал ошибок.

Exception in thread "main" javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:980)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1363)
at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:735)
at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:123)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at java.io.FilterOutputStream.close(FilterOutputStream.java:158)
at org.apache.commons.net.ftp.FTPClient._storeFile(FTPClient.java:593)
at org.apache.commons.net.ftp.FTPClient.__storeFile(FTPClient.java:557)
at org.apache.commons.net.ftp.FTPClient.storeFile(FTPClient.java:1795)
at FTPSClientManager.doSend(FTPSClientManager.java:50)
at FTPSClientManager.main(FTPSClientManager.java:16)
Caused by: java.io.EOFException: SSL peer shut down incorrectly
at sun.security.ssl.InputRecord.read(InputRecord.java:505)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:961)
... 11 more

Это журнал Сервера. А ниже - журнал моего сервера.

(000047)2017-04-26 오후 17:12:33 - admin (192.168.56.1)> 230 Logged on
(000047)2017-04-26 오후 17:12:33 - admin (192.168.56.1)> TYPE I
(000047)2017-04-26 오후 17:12:33 - admin (192.168.56.1)> 200 Type set to I
(000047)2017-04-26 오후 17:12:33 - admin (192.168.56.1)> PBSZ 0
(000047)2017-04-26 오후 17:12:33 - admin (192.168.56.1)> 200 PBSZ=0
 (000047)2017-04-26 오후 17:12:33 - admin (192.168.56.1)> PROT P
(000047)2017-04-26 오후 17:12:33 - admin (192.168.56.1)> 200 Protection level 
set to P
(000047)2017-04-26 오후 17:12:33 - admin (192.168.56.1)> PASV
(000047)2017-04-26 오후 17:12:33 - admin (192.168.56.1)> 227 Entering Passive 
Mode (192,168,56,1,233,30)
(000047)2017-04-26 오후 17:12:33 - admin (192.168.56.1)> STOR temp.txt
(000047)2017-04-26 오후 17:12:33 - admin (192.168.56.1)> 150 Opening data    
channel for file upload to server of "/temp.txt"
(000047)2017-04-26 오후 17:12:33 - admin (192.168.56.1)> 450 TLS session of 
data connection has not resumed or the session does not match the control 
connection
(000047)2017-04-26 오후 17:12:33 - admin (192.168.56.1)> disconnected.

0 ответов

Другие вопросы по тегам