Skip to content

Commit 9ec0326

Browse files
Merge pull request #62 from Gabriel3G/master
Fix issue where setting keystore/truststore type to pkcs12 by default…
2 parents 4556ff3 + a5f7b8c commit 9ec0326

File tree

1 file changed

+34
-10
lines changed

1 file changed

+34
-10
lines changed

src/main/java/io/github/delirius325/jmeter/backendlistener/elasticsearch/ElasticsearchBackendClient.java

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,17 +169,41 @@ private void convertParameterToSet(BackendListenerContext context, String parame
169169
* @param context
170170
*/
171171
private void setSSLConfiguration(BackendListenerContext context) {
172-
System.setProperty("javax.net.ssl.keyStore", context.getParameter(ES_SSL_KEYSTORE_PATH));
173-
System.setProperty("javax.net.ssl.keyStorePassword", context.getParameter(ES_SSL_KEYSTORE_PW));
174-
System.setProperty("javax.net.ssl.keyStoreType",
175-
FilenameUtils.getExtension(context.getParameter(ES_SSL_KEYSTORE_PATH)).equals("jks") ? "jks" : "pkcs12");
176-
//jks (.jks) or pkcs12 (.p12)
172+
String keyStorePath = context.getParameter(ES_SSL_KEYSTORE_PATH);
173+
if (!keyStorePath.equalsIgnoreCase("")) {
174+
logger.warn("KeyStore system properties overwritten by ES SSL configuration.");
175+
System.setProperty("javax.net.ssl.keyStore", keyStorePath);
176+
System.setProperty("javax.net.ssl.keyStorePassword", context.getParameter(ES_SSL_KEYSTORE_PW));
177+
switch (FilenameUtils.getExtension(keyStorePath)) {
178+
case "jks":
179+
System.setProperty("javax.net.ssl.keyStoreType", "jks");
180+
break;
181+
case "p12":
182+
System.setProperty("javax.net.ssl.keyStoreType", "pkcs12");
183+
break;
184+
default:
185+
System.setProperty("javax.net.ssl.keyStoreType", "");
186+
break;
187+
}
188+
}
177189

178-
System.setProperty("javax.net.ssl.trustStore", context.getParameter(ES_SSL_TRUSTSTORE_PATH));
179-
System.setProperty("javax.net.ssl.trustStorePassword", context.getParameter(ES_SSL_TRUSTSTORE_PW));
180-
System.setProperty("javax.net.ssl.trustStoreType",
181-
FilenameUtils.getExtension(context.getParameter(ES_SSL_TRUSTSTORE_PATH)).equals("jks") ? "jks"
182-
: "pkcs12");
190+
String trustStorePath = context.getParameter(ES_SSL_TRUSTSTORE_PATH);
191+
if (!trustStorePath.equalsIgnoreCase("")) {
192+
logger.warn("TrustStore system properties overwritten by ES SSL configuration.");
193+
System.setProperty("javax.net.ssl.trustStore", trustStorePath);
194+
System.setProperty("javax.net.ssl.trustStorePassword", context.getParameter(ES_SSL_TRUSTSTORE_PW));
195+
switch (FilenameUtils.getExtension(trustStorePath)) {
196+
case "jks":
197+
System.setProperty("javax.net.ssl.trustStoreType", "jks");
198+
break;
199+
case "p12":
200+
System.setProperty("javax.net.ssl.trustStoreType", "pkcs12");
201+
break;
202+
default:
203+
System.setProperty("javax.net.ssl.trustStoreType", "");
204+
break;
205+
}
206+
}
183207

184208
}
185209

0 commit comments

Comments
 (0)