mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2024-11-22 16:56:40 -06:00
Improve SSLKsFactory
Use kspass (keystore password) as the keyPassword if keyPassword is not specified
This commit is contained in:
parent
563e792ffb
commit
8f2da8f448
@ -87,16 +87,16 @@ public class SSLKsFactory {
|
||||
logger.warn("Please update your 'ssl=true' parameter to 'ssl=jdk'");
|
||||
}
|
||||
|
||||
final char[] keyStorePassword = def.getParams().getOptionalString("kspass")
|
||||
.map(String::toCharArray)
|
||||
.orElse(null);
|
||||
keyPassword = def.getParams().getOptionalString("keyPassword")
|
||||
.map(String::toCharArray)
|
||||
.orElse(null);
|
||||
.orElse(keyStorePassword);
|
||||
|
||||
keyStore = def.getParams().getOptionalString("keystore").map(ksPath -> {
|
||||
try {
|
||||
return KeyStore.getInstance(new File(ksPath),
|
||||
def.getParams().getOptionalString("kspass")
|
||||
.map(String::toCharArray)
|
||||
.orElse(null));
|
||||
return KeyStore.getInstance(new File(ksPath), keyStorePassword);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Unable to load the keystore. Please check.", e);
|
||||
}
|
||||
|
@ -43,8 +43,21 @@ public class SSLKsFactoryTest {
|
||||
"truststore=src/test/resources/ssl/server_truststore.p12",
|
||||
"tspass=nosqlbench_server",
|
||||
"keystore=src/test/resources/ssl/client.p12",
|
||||
"kspass=nosqlbench_client"
|
||||
};
|
||||
ActivityDef activityDef = ActivityDef.parseActivityDef(String.join(";", params));
|
||||
assertThat(SSLKsFactory.get().getContext(activityDef)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJdkGetContextWithTruststoreAndKeystoreAndDifferentKeyPassword() {
|
||||
String[] params = {
|
||||
"ssl=jdk",
|
||||
"truststore=src/test/resources/ssl/server_truststore.p12",
|
||||
"tspass=nosqlbench_server",
|
||||
"keystore=src/test/resources/ssl/client_diff_password.p12",
|
||||
"kspass=nosqlbench_client",
|
||||
"keyPassword=nosqlbench_client"
|
||||
"keyPassword=nosqlbench"
|
||||
};
|
||||
ActivityDef activityDef = ActivityDef.parseActivityDef(String.join(";", params));
|
||||
assertThat(SSLKsFactory.get().getContext(activityDef)).isNotNull();
|
||||
@ -66,8 +79,19 @@ public class SSLKsFactoryTest {
|
||||
String[] params = {
|
||||
"ssl=jdk",
|
||||
"keystore=src/test/resources/ssl/client.p12",
|
||||
"kspass=nosqlbench_client"
|
||||
};
|
||||
ActivityDef activityDef = ActivityDef.parseActivityDef(String.join(";", params));
|
||||
assertThat(SSLKsFactory.get().getContext(activityDef)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJdkGetContextWithKeystoreAndDifferentKeyPassword() {
|
||||
String[] params = {
|
||||
"ssl=jdk",
|
||||
"keystore=src/test/resources/ssl/client_diff_password.p12",
|
||||
"kspass=nosqlbench_client",
|
||||
"keyPassword=nosqlbench_client"
|
||||
"keyPassword=nosqlbench"
|
||||
};
|
||||
ActivityDef activityDef = ActivityDef.parseActivityDef(String.join(";", params));
|
||||
assertThat(SSLKsFactory.get().getContext(activityDef)).isNotNull();
|
||||
|
BIN
engine-api/src/test/resources/ssl/client_diff_password.p12
Normal file
BIN
engine-api/src/test/resources/ssl/client_diff_password.p12
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user