1 String responseContent = "";
2 try {
3 SSLContextBuilder contextBuilder = new SSLContextBuilder();
4 contextBuilder.loadTrustMaterial(null, new TrustSelfSignedStrategy());
5 SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(contextBuilder.build());
6 CloseableHttpClient httpclient = HttpClients.custom().setSSLSocketFactory(sslConnectionSocketFactory).build();
7 HttpGet httpGet = new HttpGet(requestUrl);
8 CloseableHttpResponse response = httpclient.execute(httpGet);
9 try {
10 HttpEntity entity = response.getEntity();
11 if (null != entity) {
12 responseContent = EntityUtils.toString(entity, ContentType.getOrDefault(entity).getCharset());
13 EntityUtils.consume(entity);
14 }
15 } finally {
16 response.close();
17 }
18 } catch (KeyStoreException e) {
19 e.printStackTrace();
20 } catch (NoSuchAlgorithmException e) {
21 e.printStackTrace();
22 } catch (KeyManagementException e) {
23 e.printStackTrace();
24 }
25 return responseContent;