• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Making HttpsURLConnection behind a proxy

Sowmya Karmali
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>.
Proxy returns "HTTP/1.1 200 Connection established"
at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.a([DashoPro-V
at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.doConnect([Da
at com.sun.net.ssl.internal.www.protocol.https.NetworkClient.openServer(
at com.sun.net.ssl.internal.www.protocol.https.HttpClient.l([DashoPro-V1
at com.sun.net.ssl.internal.www.protocol.https.HttpClient.<init>([DashoP
at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.<init>([Dasho
at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.a([DashoPro-V
at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.a([DashoPro-V
at com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnection.connec
at com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnection.getInp
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic