mirror of https://github.com/apache/nifi.git
NIFI-5479: Using the SUN provider when the keystore type is JKS.
This closes #2961. Signed-off-by: Koji Kawamura <ijokarumawak@apache.org>
This commit is contained in:
parent
a27ccd8a56
commit
f04cd8681d
|
@ -29,6 +29,8 @@ import java.security.Security;
|
|||
public class KeyStoreUtils {
|
||||
private static final Logger logger = LoggerFactory.getLogger(KeyStoreUtils.class);
|
||||
|
||||
public static final String SUN_PROVIDER_NAME = "SUN";
|
||||
|
||||
static {
|
||||
Security.addProvider(new BouncyCastleProvider());
|
||||
}
|
||||
|
@ -42,6 +44,8 @@ public class KeyStoreUtils {
|
|||
public static String getKeyStoreProvider(String keyStoreType) {
|
||||
if (KeystoreType.PKCS12.toString().equalsIgnoreCase(keyStoreType)) {
|
||||
return BouncyCastleProvider.PROVIDER_NAME;
|
||||
} else if (KeystoreType.JKS.toString().equalsIgnoreCase(keyStoreType)) {
|
||||
return SUN_PROVIDER_NAME;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ import java.lang.reflect.InvocationTargetException;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.nifi.security.util.KeyStoreUtils.SUN_PROVIDER_NAME;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
@ -107,7 +108,7 @@ public class JettyServerTest {
|
|||
JettyServer.configureSslContextFactory(contextFactory, nifiProperties);
|
||||
|
||||
verify(contextFactory).setKeyStoreType(keyStoreType);
|
||||
verify(contextFactory, never()).setKeyStoreProvider(anyString());
|
||||
verify(contextFactory).setKeyStoreProvider(SUN_PROVIDER_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -137,7 +138,7 @@ public class JettyServerTest {
|
|||
JettyServer.configureSslContextFactory(contextFactory, nifiProperties);
|
||||
|
||||
verify(contextFactory).setTrustStoreType(trustStoreType);
|
||||
verify(contextFactory, never()).setTrustStoreProvider(anyString());
|
||||
verify(contextFactory).setTrustStoreProvider(SUN_PROVIDER_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue