Skip to content

Commit

Permalink
Must put resolved hostname of data socket into session cache.
Browse files Browse the repository at this point in the history
Former-commit-id: 5ee46b4632083e54cc0e588c6967c0e34d2258b4
  • Loading branch information
dkocher committed Apr 10, 2013
1 parent 3210598 commit aea9445
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion source/ch/cyberduck/core/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ protected void setDefaults() {
*/
defaults.put("ftp.tls.datachannel", "P"); //C
defaults.put("ftp.tls.session.requirereuse", String.valueOf(true));
defaults.put("ftp.ssl.session.cache.size", String.valueOf(100));

/**
* Try to determine the timezone automatically using timestamp comparison from MLST and LIST
Expand Down Expand Up @@ -748,7 +749,6 @@ protected void setDefaults() {
defaults.put("connection.unsecure.switch", String.valueOf(true));

defaults.put("connection.ssl.protocols", "SSLv3, TLSv1");
defaults.put("connection.ssl.session.cache.size", String.valueOf(100));

/**
* Transfer read buffer size
Expand Down
12 changes: 6 additions & 6 deletions source/ch/cyberduck/core/ftp/FTPClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,16 @@ protected void _prepareDataSocket_(final Socket socket) throws IOException {
// Control socket is SSL
final SSLSession session = ((SSLSocket) _socket_).getSession();
final SSLSessionContext context = session.getSessionContext();
context.setSessionCacheSize(Preferences.instance().getInteger("connection.ssl.session.cache.size"));
context.setSessionCacheSize(Preferences.instance().getInteger("ftp.ssl.session.cache.size"));
try {
final Field sessionHostPortCache = context.getClass().getDeclaredField("sessionHostPortCache");
sessionHostPortCache.setAccessible(true);
final Object cachedSession = sessionHostPortCache.get(context);
final String key = String.format("%s:%s", socket.getInetAddress().getHostAddress(),
String.valueOf(socket.getPort())).toLowerCase(Locale.ROOT);
final Method method = cachedSession.getClass().getDeclaredMethod("put", Object.class, Object.class);
final Object cache = sessionHostPortCache.get(context);
final Method method = cache.getClass().getDeclaredMethod("put", Object.class, Object.class);
method.setAccessible(true);
method.invoke(cachedSession, key, session);
final String key = String.format("%s:%s", socket.getInetAddress().getHostName(),
String.valueOf(socket.getPort())).toLowerCase(Locale.ROOT);
method.invoke(cache, key, session);
}
catch(NoSuchFieldException e) {
// Not running in expected JRE
Expand Down

0 comments on commit aea9445

Please sign in to comment.