netlayer icon indicating copy to clipboard operation
netlayer copied to clipboard

TorSocket.isConnected always returns false

Open craigraw opened this issue 4 years ago • 0 comments

TorSocket delegates the socket.isConnected() call to SocksSocket which always returns false, even when the TorSocket has successfully connected to the endpoint.

This is a problem when wrapping the TorSocket in a java SSLSocket, as the first thing that SSLSocketImpl does is check if the socket is connected: if (!sock.isConnected()) { throw new SocketException("Underlying socket is not connected"); }

While it's unnecessary to wrap Tor connections in SSL, sometimes you don't get a choice of server protocol.

A workaround is to use Java reflection to retrieve SocksSocket from TorSocket and set the connected member variable to true.

craigraw avatar Sep 14 '20 06:09 craigraw