summaryrefslogtreecommitdiffstats
path: root/adaptors
diff options
context:
space:
mode:
Diffstat (limited to 'adaptors')
-rw-r--r--adaptors/base/http/provider/src/main/java/org/onap/ccsdk/sli/adaptors/base/http/AbstractHttpAdapter.java9
-rw-r--r--adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/RestService.java5
-rwxr-xr-xadaptors/message-router/consumer/provider/pom.xml5
-rwxr-xr-xadaptors/message-router/consumer/provider/src/main/java/org/onap/ccsdk/sli/adaptors/messagerouter/consumer/provider/impl/AbstractBaseConsumer.java10
4 files changed, 14 insertions, 15 deletions
diff --git a/adaptors/base/http/provider/src/main/java/org/onap/ccsdk/sli/adaptors/base/http/AbstractHttpAdapter.java b/adaptors/base/http/provider/src/main/java/org/onap/ccsdk/sli/adaptors/base/http/AbstractHttpAdapter.java
index 65cbdd764..0950ceba8 100644
--- a/adaptors/base/http/provider/src/main/java/org/onap/ccsdk/sli/adaptors/base/http/AbstractHttpAdapter.java
+++ b/adaptors/base/http/provider/src/main/java/org/onap/ccsdk/sli/adaptors/base/http/AbstractHttpAdapter.java
@@ -10,6 +10,7 @@ import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
import javax.ws.rs.client.ClientBuilder;
+import org.onap.ccsdk.sli.core.utils.common.AcceptIpAddressHostNameVerifier;
import org.onap.ccsdk.sli.core.utils.common.EnvProperties;
import org.onap.logging.filter.base.MetricLogClientFilter;
import org.onap.logging.filter.base.PayloadLoggingClientFilter;
@@ -32,12 +33,8 @@ public abstract class AbstractHttpAdapter {
}
private void defaultHostNameVerifier() {
- clientBuilder.hostnameVerifier(new HostnameVerifier() {
- @Override
- public boolean verify(String hostname, SSLSession session) {
- return true;
- }
- });
+ // Perform host name verification EXCEPT if 'host' is IP address
+ clientBuilder.hostnameVerifier(new AcceptIpAddressHostNameVerifier());
}
protected void enableMetricLogging() {
diff --git a/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/RestService.java b/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/RestService.java
index ebddc24ae..7f90ab43d 100644
--- a/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/RestService.java
+++ b/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/RestService.java
@@ -22,6 +22,7 @@
package org.onap.ccsdk.sli.adaptors.resource.mdsal;
import org.apache.commons.codec.binary.Base64;
+import org.onap.ccsdk.sli.core.utils.common.AcceptIpAddressHostNameVerifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
@@ -90,8 +91,8 @@ public class RestService {
try {
HttpURLConnection conn = getRestConnection(fullUrl, method);
if (conn instanceof HttpsURLConnection) {
- HostnameVerifier hostnameVerifier = (hostname, session) -> true;
- ((HttpsURLConnection) conn).setHostnameVerifier(hostnameVerifier);
+ // Safely disable host name verification if host is an IP address or 'localhost'
+ ((HttpsURLConnection) conn).setHostnameVerifier(new AcceptIpAddressHostNameVerifier());
}
// Write message
diff --git a/adaptors/message-router/consumer/provider/pom.xml b/adaptors/message-router/consumer/provider/pom.xml
index 6eb580373..c3b6ef35b 100755
--- a/adaptors/message-router/consumer/provider/pom.xml
+++ b/adaptors/message-router/consumer/provider/pom.xml
@@ -27,6 +27,11 @@
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>utils-provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<build>
diff --git a/adaptors/message-router/consumer/provider/src/main/java/org/onap/ccsdk/sli/adaptors/messagerouter/consumer/provider/impl/AbstractBaseConsumer.java b/adaptors/message-router/consumer/provider/src/main/java/org/onap/ccsdk/sli/adaptors/messagerouter/consumer/provider/impl/AbstractBaseConsumer.java
index 8937f7b91..7924137ad 100755
--- a/adaptors/message-router/consumer/provider/src/main/java/org/onap/ccsdk/sli/adaptors/messagerouter/consumer/provider/impl/AbstractBaseConsumer.java
+++ b/adaptors/message-router/consumer/provider/src/main/java/org/onap/ccsdk/sli/adaptors/messagerouter/consumer/provider/impl/AbstractBaseConsumer.java
@@ -36,6 +36,7 @@ import javax.net.ssl.SSLSession;
import org.onap.ccsdk.sli.adaptors.messagerouter.consumer.api.ConsumerApi;
import org.onap.ccsdk.sli.adaptors.messagerouter.consumer.api.RequestHandler;
+import org.onap.ccsdk.sli.core.utils.common.AcceptIpAddressHostNameVerifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -163,15 +164,10 @@ public abstract class AbstractBaseConsumer implements ConsumerApi {
httpUrlConnection.setConnectTimeout(connectTimeout);
httpUrlConnection.setReadTimeout(readTimeout);
- // ignore hostname errors when dealing with HTTPS connections
+ // Safely ignore hostname errors if host is an ip address or localhost
if (httpUrlConnection instanceof HttpsURLConnection) {
HttpsURLConnection conn = (HttpsURLConnection) httpUrlConnection;
- conn.setHostnameVerifier(new HostnameVerifier() {
- @Override
- public boolean verify(String arg0, SSLSession arg1) {
- return true;
- }
- });
+ conn.setHostnameVerifier(new AcceptIpAddressHostNameVerifier());
}
return httpUrlConnection;
}