public SSLSessionContext getSessionContext() { return unwrap().getSessionContext(); }
@Override public SSLSessionContext getSessionContext() { return delegate().getSessionContext(); }
@Override public SSLSessionContext getSessionContext() { return unwrap().getSessionContext(); }
public SSLSessionContext getSessionContext() { return unwrap().getSessionContext(); }
@Override public SSLSessionContext getSessionContext() { return unwrap().getSessionContext(); }
@Override public SSLSessionContext getSessionContext() { return unwrap().getSessionContext(); }
public SSLSessionContext getSessionContext() { return unwrap().getSessionContext(); }
@Override protected void _prepareDataSocket_(final Socket socket) throws IOException { if(preferences.getBoolean("ftp.tls.session.requirereuse")) { if(socket instanceof SSLSocket) { // Control socket is SSL final SSLSession session = ((SSLSocket) _socket_).getSession(); final SSLSessionContext context = session.getSessionContext(); context.setSessionCacheSize(preferences.getInteger("ftp.ssl.session.cache.size")); try { final Field sessionHostPortCache = context.getClass().getDeclaredField("sessionHostPortCache"); sessionHostPortCache.setAccessible(true); final Object cache = sessionHostPortCache.get(context); final Method method = cache.getClass().getDeclaredMethod("put", Object.class, Object.class); method.setAccessible(true); 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 log.warn("No field sessionHostPortCache in SSLSessionContext", e); } catch(Exception e) { // Not running in expected JRE log.warn(e.getMessage()); } } } }
@Override protected void _prepareDataSocket_(final Socket socket) throws IOException { super._prepareDataSocket_(socket); if (myShareSslContext && socket instanceof SSLSocket) { final SSLSession session = ((SSLSocket) _socket_).getSession(); final SSLSessionContext context = session.getSessionContext(); try { final Field sessionHostPortCache = context.getClass().getDeclaredField("sessionHostPortCache"); sessionHostPortCache.setAccessible(true); final Object cache = sessionHostPortCache.get(context); final Method putMethod = cache.getClass().getDeclaredMethod("put", Object.class, Object.class); putMethod.setAccessible(true); Class<? extends Socket> socketClass = socket.getClass(); Method getHostMethod; try { getHostMethod = socketClass.getMethod("getPeerHost"); } catch (NoSuchMethodException e) { getHostMethod = socketClass.getDeclaredMethod("getHost"); getHostMethod.setAccessible(true); } Object host = getHostMethod.invoke(socket); final String key = String.format("%s:%s", host, String.valueOf(socket.getPort())).toLowerCase(Locale.ROOT); putMethod.invoke(cache, key, session); } catch (Exception e) { throw new IOException(e); } } } //[IntelliJ] WI-18980 Connectionproblems with FTPS. "session reuse required" on vsFTPd/pure-ftd/proftpd -----
/** * Used for printing out more info when there's a problem. * * @param socket */ protected void printSslSocketInfo(SSLSocket socket) { System.out.println("Socket: " + socket); SSLSession session = socket.getSession(); if (session != null) { System.out.println("Session: " + session); System.out.println(" Local certificates: " + (session.getLocalCertificates() != null ? Arrays .asList(session.getLocalCertificates()) : null)); System.out.println(" Local principal: " + session.getLocalPrincipal()); SSLSessionContext context = session.getSessionContext(); if (context != null) { System.out.println("Session context: " + context); } } }
final SSLSessionContext context = session.getSessionContext(); context.setSessionCacheSize(preferences.getInteger("ftp.ssl.session.cache.size")); try {