import java.net.URL;
import java.net.HttpURLConnection;
+import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLException;
+import javax.net.ssl.SSLSession;
import org.apache.commons.codec.binary.Base64;
import org.onap.dmaap.dbcapi.logging.BaseLoggingClass;
private String mmProvCred;
private String unit_test;
private boolean useAAF;
-
+ private boolean hostnameVerify;
public MrTopicConnection(String user, String pwd ) {
mmProvCred = new String( user + ":" + pwd );
DmaapConfig p = (DmaapConfig)DmaapConfig.getConfig();
unit_test = p.getProperty( "UnitTest", "No" );
useAAF= "true".equalsIgnoreCase(p.getProperty("UseAAF", "false"));
+ hostnameVerify= "true".equalsIgnoreCase(p.getProperty("MR.hostnameVerify", "true"));
}
public boolean makeTopicConnection( MR_Cluster cluster, String topic, String overrideFqdn ) {
return makeConnection( topicURL );
}
+
private boolean makeSecureConnection( String pURL ) {
logger.info( "makeConnection to " + pURL );
-
+
try {
+ HostnameVerifier hostnameVerifier = new HostnameVerifier() {
+ @Override
+ public boolean verify( String hostname, SSLSession session ) {
+ return true;
+ }
+
+ };
+
+
URL u = new URL( pURL );
- uc = (HttpsURLConnection) u.openConnection();
+ uc = (HttpsURLConnection) u.openConnection();
uc.setInstanceFollowRedirects(false);
+ if ( ! hostnameVerify ) {
+ HttpsURLConnection ucs = (HttpsURLConnection) uc;
+ ucs.setHostnameVerifier(hostnameVerifier);
+ }
+
logger.info( "open connection to " + pURL );
return(true);
} catch (Exception e) {