From 4e4988af6aa561d4950711322941cab8c2d2c895 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Fri, 9 Jul 2021 10:20:56 -0400 Subject: 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 Change-Id: I83cec989102620b52a227b7ca71efb92227d834c --- .../java/org/onap/ccsdk/sli/adaptors/resource/mdsal/RestService.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'adaptors/mdsal-resource') 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 -- cgit 1.2.3-korg