throws IOException { Socket socket = super._openDataConnection_(command, arg); _prepareDataSocket_(socket); if (socket instanceof SSLSocket) { SSLSocket sslSocket = (SSLSocket)socket;
@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 -----