On Mon, 2010-07-05 at 08:56 -0700, Jacky-Zhu-1 wrote: > > > olegk wrote: > > > > On Sun, 2010-07-04 at 11:39 -0700, Jacky-Zhu-1 wrote: > >> I've been trying to use httpclient4.0 to connect https server via socks > >> proxy, but it failed again and again. > >> > > > > SOCKS is a TCP/IP level, not HTTP level protocol. SOCKS proxy support > > can be configured using standard JVM settings. > > > > Oleg > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: [email protected] > > > > > > > > Hi Oleg, thanks for your reply. > You are right, SOCKS proxy support could be configured using standard JVM > settings. But JVM settings is global, it will take effect for all the java > socket, this is not what we want, we just want to use SOCKS proxy for part > of the java sockets, so we want to go through the SOCKS by using HttpClient. > Yes, SOCKS is TCP/IP level, HttpClient focus on HTTP level. But HttpClient > supports to create customized socket by implementing the > SocketFactory/LayeredSocketFactory, am I right? > And JVM supports layered SSLSocket, I've checked the JVM code and the JSSE > code, JVM could support to let user pass one connected socket to one > SSLSocket. > > So the solution I have tried is something like this: > 1. create one normal socket, and connect it to the proxy server > 2. complete the socks protocol using this socket > 3. passed this socket to a new created SSLSocket > 4. let HttpClient use this new SSLSocket to communicate with HTTPS server > > I've checked the running status, the steps 1/2/3 are all ok, but the step 4 > failed, as the log I have pasted. > > Could you give me some advices? > Or maybe I can read the HttpClient source code to get some clues. >
Have a look at this example. Please note it requires HttpClient 4.1 (still ALPHA) http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientExecuteSOCKS.java Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
