diff options
author | Dan Timoney <dtimoney@att.com> | 2021-07-09 10:20:56 -0400 |
---|---|---|
committer | KAPIL SINGAL <ks220y@att.com> | 2021-07-09 17:22:17 +0000 |
commit | 4e4988af6aa561d4950711322941cab8c2d2c895 (patch) | |
tree | 65c6190636ffa13092badc58b5f1d16dc56db65c /adaptors/message-router/consumer/provider | |
parent | 2ab339240c1d0bd8246bebb75d12c4849dd9e4c5 (diff) |
Add host name verifier that accepts IP addresses
Add a host name verifier that handles IP addresses as special cases,
so that they can be safely ignored in lab environments
Issue-ID: CCSDK-3196
Signed-off-by: Dan Timoney <dtimoney@att.com>
Change-Id: I83cec989102620b52a227b7ca71efb92227d834c
Diffstat (limited to 'adaptors/message-router/consumer/provider')
2 files changed, 8 insertions, 7 deletions
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; } |