1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
URI trustStore = getClass().getClassLoader().getResource("trustStore.jks").toURI();
SSLContext sslcontext = SSLContexts.custom()
.loadTrustMaterial(new File(trustStore), "******".toCharArray())
.build();
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext,
SSLConnectionSocketFactory.getDefaultHostnameVerifier());
CloseableHttpClient httpclient = HttpClients.custom()
.setProxy(new HttpHost("myproxy", 8080))
.setSSLSocketFactory(sslsf)
.build();
CloseableHttpResponse response = httpclient.execute(new HttpGet("https://service.annuaire.sante.fr/"));
InputStream is = response.getEntity().getContent();
byte[] b = new byte[100000];
is.read(b);
System.err.println(b.toString()); |