Andriy Dmytruk
Andriy Dmytruk

Reputation: 47

Java SSLSocket reuse session for different port

I am using the org.apache.commons.net.ftp.FTPSClient for download files from external ftp server. This server is no managed by me and it is configured with option "require_ssl_reuse" enabled. Which means, as I understand, that same session must be used for command and data connection.

For command connection port 21 is used but for data the port is selected from range of not used ports. So when after successful connection to server I try yo list directory the connection is closed due to this restriction.

Internally the java client uses SSLSockets. Is it possible to reuse SSLSession for the same IP but different ports? Do somebody knows the java client which supports ssl session reuse?

Thanks in advance!

Upvotes: 2

Views: 1090

Answers (2)

user207421
user207421

Reputation: 310978

SSL sessions aren't bound to specific ports, and JSSE already supports session resumption.

This should work out of the box.

Do you have some evidence that it isn't?

Upvotes: 1

Andriy Dmytruk
Andriy Dmytruk

Reputation: 47

I have found the solution! It is the FTPClient class from Cyberduck core. Its extends FTPSClient from org.apache.commons.net and reuse Session injecting it to SSLSocket using java reflection.

Upvotes: 1

Related Questions