Making HttpsURLConnection from behind a Proxy
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Sowmya_Karmali
Posted On:   Wednesday, June 5, 2002 07:33 AM

I am trying to connect to a secure site from a java application (not browser) on a redhat linux 7.2 machine. The linux machine is behind a firewall. when i specify the proxyHost and proxyPort (https.proxyHost,https.proxyPort) in my application i get an IOException saying - Exception in thread "main" java.io.IOException: Unable to tunnel through . Proxy returns "HTTP/1.1 200 Connection established" at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.a([DashoPro-V 1.2-120198]) at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.doConnect([Da shoPro-V1.2-120198]) at com.sun.net.ssl.internal.www.protocol.https.NetworkClient.openServer( [DashoPro-   More>>

I am trying to connect to a secure site from a java application (not browser) on a redhat linux 7.2 machine.
The linux machine is behind a firewall.
when i specify the proxyHost and proxyPort (https.proxyHost,https.proxyPort) in my application i
get an IOException saying -
Exception in thread "main" java.io.IOException: Unable to tunnel through .
Proxy returns "HTTP/1.1 200 Connection established"
at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.a([DashoPro-V
1.2-120198])
at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.doConnect([Da
shoPro-V1.2-120198])
at com.sun.net.ssl.internal.www.protocol.https.NetworkClient.openServer(
[DashoPro-V1.2-120198])
at com.sun.net.ssl.internal.www.protocol.https.HttpClient.l([DashoPro-V1
.2-120198])
at com.sun.net.ssl.internal.www.protocol.https.HttpClient. ([DashoP
ro-V1.2-120198])
at com.sun.net.ssl.internal.www.protocol.https.HttpsClient. ([Dasho
Pro-V1.2-120198])
at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.a([DashoPro-V
1.2-120198])
at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.a([DashoPro-V
1.2-120198])
at com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnection.connec
t([DashoPro-V1.2-120198])
at com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnection.getInp
utStream([DashoPro-V1.2-120198])
at URLTunnelReader.main(URLTunnelReader.java:29)

This is bcos JSSE currently accepts http/1.0 response only from the proxy.
I found an article on javaworld (tip 111) and did what the article said:
Create a class SSLTunnelSocketFactory that extends SSLSocketFactory, and in that have a method which works around this by looking for the string "200 connection established" instead of "HTTP/1.0 200", which the DefaultSSLSocketFactory does.

Now, the SSL handshake is happening, but the createSocket() method from the proxy to the secure site still fails.


Can anyone tell me why is this happening and is there a workaround available?

thanks and Regards
Sowmya.

   <<Less
About | Sitemap | Contact