From d6427a753cc4962f92f8d07d8ed184c83dc7c029 Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Mon, 29 Jan 2018 10:38:40 -0500 Subject: Do not enforce hostname validation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I1c4e5d58126e35a64140c91c0c3afda5e9b3a5bd Issue-ID: POLICY-510 Signed-off-by: Alexis de Talhouët --- .../src/main/java/org/onap/policy/rest/RESTManager.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'controlloop/common/model-impl') diff --git a/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java b/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java index 2540cb27a..dae31c39a 100644 --- a/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java +++ b/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java @@ -30,6 +30,7 @@ import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.CredentialsProvider; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; +import org.apache.http.conn.ssl.NoopHostnameVerifier; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.client.CloseableHttpClient; @@ -67,7 +68,11 @@ public class RESTManager { logger.debug(body); try (CloseableHttpClient client = - HttpClientBuilder.create().setDefaultCredentialsProvider(credentials).build()) { + HttpClientBuilder + .create() + .setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE) + .setDefaultCredentialsProvider(credentials) + .build()) { HttpPost post = new HttpPost(url); if (headers != null) { @@ -111,7 +116,11 @@ public class RESTManager { new UsernamePasswordCredentials(username, password)); try (CloseableHttpClient client = - HttpClientBuilder.create().setDefaultCredentialsProvider(credentials).build()) { + HttpClientBuilder + .create() + .setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE) + .setDefaultCredentialsProvider(credentials) + .build()) { HttpGet get = new HttpGet(url); if (headers != null) { -- cgit 1.2.3-korg