NIFI-6847 - fixed NPE in TLS toolkit when used in client mode with SANs (#3871)

This commit is contained in:
Pierre Villard 2019-11-05 19:41:01 +01:00 committed by Andy LoPresto
parent a9db5a8cb7
commit 481f9f67bf
2 changed files with 18 additions and 2 deletions

View File

@ -72,14 +72,23 @@ public class InstanceDefinition {
protected static InstanceDefinition createDefinition(InstanceIdentifier instanceIdentifier, int number, Supplier<String> keyStorePasswords, Supplier<String> keyPasswords,
Supplier<String> trustStorePasswords) {
String keyStorePassword = keyStorePasswords.get();
String keyStorePassword = null;
if (keyStorePasswords != null) {
keyStorePassword = keyStorePasswords.get();
}
String keyPassword;
if (keyPasswords == null) {
keyPassword = keyStorePassword;
} else {
keyPassword = keyPasswords.get();
}
String trustStorePassword = trustStorePasswords.get();
String trustStorePassword = null;
if (trustStorePasswords != null) {
trustStorePassword = trustStorePasswords.get();
}
return new InstanceDefinition(instanceIdentifier, number, keyStorePassword, keyPassword, trustStorePassword);
}

View File

@ -175,4 +175,11 @@ public class TlsCertificateAuthorityClientCommandLineTest {
tlsCertificateAuthorityClientCommandLine.parse("-t", testToken, "-C", testCertificateFile);
assertEquals(testCertificateFile, tlsCertificateAuthorityClientCommandLine.getCertificateDirectory());
}
@Test
public void testConfigClientSAN() throws CommandLineParseException {
tlsCertificateAuthorityClientCommandLine.parse("-t", testToken, "--" + TlsCertificateAuthorityClientCommandLine.SUBJECT_ALTERNATIVE_NAMES, "nifi.apache.org,minifi.apache.org");
assertEquals("nifi.apache.org", tlsCertificateAuthorityClientCommandLine.getDomainAlternativeNames().get(0));
assertEquals("minifi.apache.org", tlsCertificateAuthorityClientCommandLine.getDomainAlternativeNames().get(1));
}
}