On Mon, 2010-07-05 at 19:16 -0700, Jacky-Zhu-1 wrote: > > > olegk wrote: > > > > 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] > > > > > > > > Hi Oleg, > > Thanks for your reply. > It seems that your example is only suitable for normal socket, not suitable > for sslsocket. I also found in > http://old.nabble.com/Fw:-SOCKS-proxy-example---td28306808.html#a28306808 > another thread , you have given an similar example for HttpClient4.0, I have > tried that solution, it did work for normal socket in HttpClient4.0, but > didn't work for sslsocket. > So I think this example still cannot work for sslsocket, because for JVM > sslsocket, the only solution to using sslsocket via socks proxy is that: > create normal socket and connect it to the proxy server; complete the socks > protocol using this socket's input/output stream;create one sslsocket using > this socket. > > My problem is how to let HttpClient4.0 use this customized sslsocket..... >
That is exactly what socket factories are for http://hc.apache.org/httpcomponents-client-4.0.1/tutorial/html/connmgmt.html#d4e484 Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
