Fixed AAI ModelLoader fails to connect to aai-babel
[aai/model-loader.git] / src / main / java / org / onap / aai / modelloader / restclient / AaiRestClient.java
index 27db741..29c0c70 100644 (file)
@@ -157,12 +157,23 @@ public class AaiRestClient {
     private RestClient setupClient() {
         RestClient restClient = new RestClient();
 
-        // @formatter:off
-        restClient.validateServerHostname(false)
-                .validateServerCertChain(false)
-                .clientCertFile(config.getAaiKeyStorePath())
-                .clientCertPassword(config.getAaiKeyStorePassword());
-        // @formatter:on
+        //Use certs only if SSL is enabled
+        if (config.useHttpsWithAAI())
+        {// @formatter:off
+            restClient.validateServerHostname(false)
+                    .validateServerCertChain(false)
+                    .clientCertFile(config.getAaiKeyStorePath())
+                    .clientCertPassword(config.getAaiKeyStorePassword())
+                    .connectTimeoutMs(120000)
+                    .readTimeoutMs(120000);
+            // @formatter:on
+        }
+        else {
+            restClient.validateServerHostname(false)
+                    .validateServerCertChain(false)
+                    .connectTimeoutMs(120000)
+                    .readTimeoutMs(120000);
+        }
 
         if (useBasicAuth()) {
             restClient.authenticationMode(RestAuthenticationMode.SSL_BASIC);