Fixed issue with SSL

Override system keystore setting only if local location and local password are not null
This commit is contained in:
Keith Armstrong 2025-01-02 07:37:24 -05:00
parent 9b3cdafc98
commit 2c5bf8fe30

View File

@ -35,8 +35,11 @@ public class soapProcessor {
public static HttpURLConnection getConnection(String thisCredentials, String thisURL, Boolean thisSSL, String thisKeystore, String thisPassword) throws Exception public static HttpURLConnection getConnection(String thisCredentials, String thisURL, Boolean thisSSL, String thisKeystore, String thisPassword) throws Exception
{ {
URL url = new URL(thisURL); URL url = new URL(thisURL);
if (thisSSL) if (thisSSL && thisKeystore != null && thisPassword != null)
{ {
debugProcessor.writer(false, "SSL: " + thisSSL);
debugProcessor.writer(false, "JAVA Keystore: " + thisKeystore);
debugProcessor.writer(false, "JAVA Password: " + thisPassword);
System.setProperty("javax.net.ssl.trustStore", thisKeystore); System.setProperty("javax.net.ssl.trustStore", thisKeystore);
System.setProperty("javax.net.ssl.trustStorePassword", thisPassword); System.setProperty("javax.net.ssl.trustStorePassword", thisPassword);
} }
@ -45,12 +48,12 @@ public class soapProcessor {
URLConnection connection = url.openConnection(); URLConnection connection = url.openConnection();
if (thisCredentials != null) if (thisCredentials != null)
{ {
debugProcessor.writer(false, "We are sending credentials!"); debugProcessor.writer(false, "We are using credentials!");
connection.setRequestProperty("Authorization", "Basic " + thisCredentials); connection.setRequestProperty("Authorization", "Basic " + thisCredentials);
} }
else else
{ {
debugProcessor.writer(false, "No Credentials will be sent!"); debugProcessor.writer(false, "No credentials will be used!");
} }
HttpURLConnection httpConn = (HttpURLConnection)connection; HttpURLConnection httpConn = (HttpURLConnection)connection;
return httpConn; return httpConn;