Veera
Veera

Reputation: 1815

How to use Custom Socket Factory in apache FTPS Client

I am using FTPClient to communicate with FTP server. Its working perfectly.

Apache providing API to FTPSClient to communicate with FTP server using SSL/TLS. But it is using their own socket factory. So, I could not access the socket session.

I want to create custom socket factory, and handle the socket session manually.

Please help me.

Upvotes: 0

Views: 1181

Answers (1)

jhoule86
jhoule86

Reputation: 56

Although FTPSClient is a SocketClient, I find that it is not best to call setSocketFactory(SocketFactory) on it as methods like execProt(String) and even the FTPS connection logic will make internal calls to setSocketFactory(SocketFactory)and undo your work.

I suggest setting the SSL context as an argument to the constructor, and/or using methods such as setEnabledProtocols(String[]) and setTrustManager(TrustManager) to set the conditions for the countless SocketFactory objects that the Apache Commons code will create over the lifetime of your FTPSClient.

FYI: TrustManager objects and SSLContext objects can be configured to use your own trustStore and/or the JVM's default trustStore.

Upvotes: 1

Related Questions