我有一个http代理ip 218.106.96.211,可以通过代理访问网站。
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);
并且可以访问java中的https网站。
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");
但如果我通过代理访问https,服务器会回复HTTP/1.1 400 Bad Request
,那么在java中通过http代理访问https的正确方法是什么?