In my android App, I'm trying to connect and upload files to my FTPS server (using port 21), which is essentially FTP with TLS. The server is a FileZilla Server that works perfectly fine with the FileZilla client. I'm using the following library for the FTPS client:
gradle
implementation 'commons-net:commons-net:3.11.1' // FTP
However, I am facing the following error when I try to list directories or list names after connecting and logging in:
425 Unable to build data connection: TLS session of data connection not resumed.
From my research, I found that the Apache Commons Net library does not support TLS connection resumption, which is necessary to reuse the same TLS session for secure file transfers.
I came across this StackOverflow thread: How to connect to FTPS server with data connection using same TLS session? and have already tried implementing solutions mentioned there, but they did not work for me.
I have tried several solutions, including:
Facing the error(No field sessionsByHostAndPort in class Lcom/android/org/conscrypt/ClientSessionContext; (declaration of 'com.android.org.conscrypt.ClientSessionContext' appears in /apex/com.android.conscrypt/javalib/conscrypt.jar))
gradle
implementation 'org.bouncycastle:bctls-jdk18on:1.78.1'
However, this did not resolve the issue.
_prepareDataSocket_
method of FTPSClient, but this also did not work as intended.Given that my FTPS client is creating a new TLS session for each file transfer while the server expects the same secure session as the control connection to be reused, I am looking for guidance on how to maintain the same TLS session for data connections or any other solutions that could help resolve this issue.
For everyone facing the same issue, I finally found a solution after spending 2-3 days searching through Stack Overflow, reading blogs, etc. I got help from ferpalos's answer on Stack Overflow. However, I also had to add the RestrictionBypass dependency, as suggested by TomInCode. Now, the connection issue is resolved. However, I'm still unsure if it's entirely safe to use RestrictionBypass.