简体   繁体   English

不同端口的 Java SSLSocket 重用会话

[英]Java SSLSocket reuse session for different port

I am using the org.apache.commons.net.ftp.FTPSClient for download files from external ftp server.我正在使用 org.apache.commons.net.ftp.FTPSClient 从外部 ftp 服务器下载文件。 This server is no managed by me and it is configured with option " require_ssl_reuse " enabled.这台服务器不是我管理的,它配置了选项“ require_ssl_reuse ”。 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.对于命令连接,使用端口 21,但对于数据,端口是从未使用的端口范围中选择的。 So when after successful connection to server I try yo list directory the connection is closed due to this restriction.因此,当成功连接到服务器后,我尝试 yo list directory 由于此限制而关闭连接。

Internally the java client uses SSLSockets.在内部,java 客户端使用 SSLSockets。 Is it possible to reuse SSLSession for the same IP but different ports?是否可以为相同的 IP 但不同的端口重用 SSLSession? Do somebody knows the java client which supports ssl session reuse?有人知道支持ssl会话重用的java客户端吗?

Thanks in advance!提前致谢!

I have found the solution!我找到了解决办法! It is the FTPClient class from Cyberduck core.它是来自 Cyber​​duck 核心的FTPClient 类 Its extends FTPSClient from org.apache.commons.net and reuse Session injecting it to SSLSocket using java reflection.它从 org.apache.commons.net 扩展 FTPSClient 并重用 Session 使用 java 反射将其注入 SSLSocket。

SSL sessions aren't bound to specific ports, and JSSE already supports session resumption. SSL 会话不绑定到特定端口,并且 JSSE 已经支持会话恢复。

This should work out of the box.这应该是开箱即用的。

Do you have some evidence that it isn't?你有证据证明不是吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM