1

I have a http proxy ip 218.106.96.211 and it's possible to access a website through the proxy.

RequestConfig config = RequestConfig.custom().setProxy(new HttpHost("218.106.96.211", 80, "http")).build();
HttpGet request = new HttpGet("http://www.example.com/");
request.setConfig(config);

and it's possible to access a https website in java.

SSLContext sslcontext = SSLContexts.custom().loadTrustMaterial(new File("file.storage"), null, new TrustSelfSignedStrategy()).build();
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, new String[] { "TLSv1" }, null,SSLConnectionSocketFactory.getDefaultHostnameVerifier());
CloseableHttpClient httpclient = HttpClients.custom().setSSLSocketFactory(sslsf).build();
HttpGet httpget = new HttpGet("https://www.def.com");

but if I access the https through the proxy, server responsed HTTP/1.1 400 Bad Request, so what's the right way to access https through http proxy in java?

Malloc
  • 659
  • 2
  • 9
  • 20
  • Have you checked this: http://stackoverflow.com/questions/1511674/how-do-a-send-an-https-request-through-a-proxy-in-java – Baderous Jan 05 '16 at 10:10
  • @Baderous thanks, I did not find this in my search – Malloc Jan 05 '16 at 10:15
  • Or try http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html#d5e485 - Custom HttpRoutePlanner – bodo Jan 05 '16 at 10:16

0 Answers0