import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
loadPartners(partners);
log.info("Partners support enabled");
} catch (Exception e) {
- log.warn("Partners file could not be read, Partner support will not be enabled.", e);
+ log.warn("Partners file could not be read, Partner support will not be enabled. " + e.getMessage());
}
try (FileInputStream in = new FileInputStream(configDir + "/" + UEB_PROPERTIES_FILE_NAME)) {
uebServers = props.getProperty("servers");
log.info("UEB support enabled");
} catch (Exception e) {
- log.warn("UEB properties could not be read, UEB support will not be enabled.", e);
+ log.warn("UEB properties could not be read, UEB support will not be enabled. " + e.getMessage());
}
httpConnectTimeout = readOptionalInteger("HTTP_CONNECT_TIMEOUT_MS",DEFAULT_HTTP_CONNECT_TIMEOUT_MS);
httpReadTimeout = readOptionalInteger("HTTP_READ_TIMEOUT_MS",DEFAULT_HTTP_READ_TIMEOUT_MS);
String skipSendingStr = paramMap.get(skipSendingMessage);
p.skipSending = "true".equalsIgnoreCase(skipSendingStr);
p.convertResponse = valueOf(parseParam(paramMap, "convertResponse", false, "true"));
- p.trustStoreFileName = parseParam(paramMap, "trustStoreFileName", false, null);
- p.trustStorePassword = parseParam(paramMap, "trustStorePassword", false, null);
p.keyStoreFileName = parseParam(paramMap, "keyStoreFileName", false, null);
p.keyStorePassword = parseParam(paramMap, "keyStorePassword", false, null);
- p.ssl = p.trustStoreFileName != null && p.trustStorePassword != null && p.keyStoreFileName != null
- && p.keyStorePassword != null;
+ p.ssl = p.keyStoreFileName != null && p.keyStorePassword != null;
p.customHttpHeaders = parseParam(paramMap, "customHttpHeaders", false, null);
p.partner = parseParam(paramMap, "partner", false, null);
p.dumpHeaders = valueOf(parseParam(paramMap, "dumpHeaders", false, null));
ssl = createSSLContext(p);
}
Client client;
-
if (ssl != null) {
HttpsURLConnection.setDefaultSSLSocketFactory(ssl.getSocketFactory());
client = ClientBuilder.newBuilder().sslContext(ssl).hostnameVerifier((s, sslSession) -> true).build();
} else {
client = ClientBuilder.newBuilder().hostnameVerifier((s, sslSession) -> true).build();
}
+
setClientTimeouts(client);
// Needed to support additional HTTP methods such as PATCH
client.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
protected SSLContext createSSLContext(Parameters p) {
try (FileInputStream in = new FileInputStream(p.keyStoreFileName)) {
- System.setProperty("jsse.enableSNIExtension", "false");
- System.setProperty("javax.net.ssl.trustStore", p.trustStoreFileName);
- System.setProperty("javax.net.ssl.trustStorePassword", p.trustStorePassword);
-
HttpsURLConnection.setDefaultHostnameVerifier((string, ssls) -> true);
-
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
KeyStore ks = KeyStore.getInstance("PKCS12");
char[] pwd = p.keyStorePassword.toCharArray();
ks.load(in, pwd);
kmf.init(ks, pwd);
-
SSLContext ctx = SSLContext.getInstance("TLS");
ctx.init(kmf.getKeyManagers(), null, null);
return ctx;
}
protected static String[] getMultipleUrls(String restapiUrl) {
- List<String> urls = new ArrayList<String>();
+ List<String> urls = new ArrayList<>();
int start = 0;
for (int i = 0; i < restapiUrl.length(); i++) {
if (restapiUrl.charAt(i) == ',') {