Home >Java >javaTutorial >How to Maintain TLS Session Reuse for Data Connections in FTPS with Apache Commons Net?

How to Maintain TLS Session Reuse for Data Connections in FTPS with Apache Commons Net?

Barbara Streisand
Barbara StreisandOriginal
2024-11-09 07:25:02827browse

How to Maintain TLS Session Reuse for Data Connections in FTPS with Apache Commons Net?

How to Maintain TLS Session for Data Connection in FTPS with Apache Commons Net

Problem:

Connecting to an FTPS server that requires data connection to use the same TLS session as the control connection using Apache Commons Net.

Solution:

Requirement:

The server must support TLS session reuse for data connections.

Apache Commons Net Overriding:

Override the _prepareDataSocket_ method in a custom FTPSClient implementation to manage session reuse, similar to what Cyberduck does in its FTPClient.java.

JDK Compatibility:

In Java 8u161 and later, session reuse may not work by default. To enable it:

System.setProperty("jdk.tls.useExtendedMasterSecret", "false");

Alternative Implementation:

An alternative implementation can be found in the following Apache Commons Net JIRA issue: https://issues.apache.org/jira/browse/NET-408.

Android-Specific Considerations:

For Android, bypass SDK restrictions to access reflection fields for session management: https://issues.apache.org/jira/browse/NET-776.

Post-Java 8u161 Changes:

In newer versions of Java, sessionsByHostAndPort should be used instead of sessionHostPortCache.

The above is the detailed content of How to Maintain TLS Session Reuse for Data Connections in FTPS with Apache Commons Net?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn