使用FTPS将文件从Android传输到服务器 [英] Transfer files from android with FTPS to the server

查看:101
本文介绍了使用FTPS将文件从Android传输到服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用

正如我所说,我可以连接到服务器,但不能传输文件.如果我停用了使用PROT P时在数据连接上要求的TLS会话恢复"复选框,则传输可以正常进行.

我正在寻找一种使用库进行文件传输的方法,但是没有成功,但我知道必须有一种方法.

我为您提供了相关代码的一部分:

  TransferImagenesFTP.ftpClient = new FTPSClient();TransferImagenesFTP.ftpClient.connect(InetAddress.getByName("XXX_XXX_XX_X"),26);TransferImagenesFTP.ftpClient.enterLocalPassiveMode();TransferImagenesFTP.ftpClient.setBufferSize(1024000);TransferImagenesFTP.ftpClient.login("xxxxxx","zzzzzz");TransferImagenesFTP.ftpClient.execPROT("P");TransferImagenesFTP.ftpClient.type(FTP.BINARY_FILE_TYPE); 

谢谢您的帮助.

解决方案

您遇到的问题是 Apache FTPSClient 无法重用会话(这是已知问题),因此服务器认为您的客户端未经授权并拒绝了转移.

检出链接]

  • FlieZilla论坛[链接]
  • I am using the Apache Commons FTP library in my android application

    I am making the connection through FTPS, and although it connects perfectly to the server, I have a problem when transferring files.

    The client who orders the app, for security reasons, requests that the TLS session resumption on data connection be requested when using PROT P.

    Therefore, I have this option enabled on the server:

    As I said, I can connect to the server, but not transfer files. If I deactivate the "Required TLS session resumption on data connection when using PROT P" box, the transfer works correctly.

    I'm looking for a way to make file transfers using the library, but without success, however, I understand that there must be a way.

    I give you the part of the related code:

    TransferImagenesFTP.ftpClient = new FTPSClient();
    
    TransferImagenesFTP.ftpClient.connect(InetAddress.getByName("XXX_XXX_XX_X"), 26);
    TransferImagenesFTP.ftpClient.enterLocalPassiveMode();
    TransferImagenesFTP.ftpClient.setBufferSize(1024000);
    TransferImagenesFTP.ftpClient.login("xxxxxx", "zzzzzz");
    TransferImagenesFTP.ftpClient.execPROT("P");
    TransferImagenesFTP.ftpClient.type(FTP.BINARY_FILE_TYPE);
    

    I appreciate any help, thanks.

    解决方案

    The problem in your case is that the Apache FTPSClient doesn't support TLS session resumption and , thus, fails when you try to transfer the file.

    Understanding the Problem

    When you connect to an FTP server over TLS, the server intiates a secure ssl session with the client on the control connection. The client then enter passive mode by sending a PASV command and in response the server opens a random unprivileged port and sends in response the port number to the client. This port represents the data connection. Now to connect to this new port securely, the client must reuse the existing TLS session that it already have with the server on the control connection.

    Why to reuse the TLS session?

    Not requiring session resumption allows session stealing attacks. The problem with FTP is that the data connection does not authenticate the client.
    If the server/client doesn't reuse the existing TLS session, it might have been possible for an attacker to connect to the data port instead and upload a malware. So to protect against such attack, the FTP server requires the client to reuse the already established session.

    In your case, the Apache FTPSClient fails to reuse the session (it's a known issue) and thus the server thinks your client is unauthorized and denies the transfer.

    Checkout the Wealthfront post on how to patch and a sample implementation.

    Sources:

    • Wealthfront [link]
    • Slacksite [link]
    • FlieZilla Forum [link]

    这篇关于使用FTPS将文件从Android传输到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆