@Test public void testLoadJKSKeyStoreAutodetectStoreFileType() throws Exception { // Make sure we can instantiate a key manager from the JKS file on disk X509KeyManager km = X509Util.createKeyManager( x509TestContext.getKeyStoreFile(KeyStoreFileType.JKS).getAbsolutePath(), x509TestContext.getKeyStorePassword(), null /* null StoreFileType means 'autodetect from file extension' */); }
@Test(expected = X509Exception.KeyManagerException.class) public void testLoadJKSKeyStoreWithWrongPassword() throws Exception { // Attempting to load with the wrong key password should fail X509KeyManager km = X509Util.createKeyManager( x509TestContext.getKeyStoreFile(KeyStoreFileType.JKS).getAbsolutePath(), "wrong password", KeyStoreFileType.JKS.getPropertyValue()); }
@Test public void testLoadPEMKeyStoreNullPassword() throws Exception { if (!x509TestContext.getKeyStorePassword().isEmpty()) { return; } // Make sure that empty password and null password are treated the same X509KeyManager km = X509Util.createKeyManager( x509TestContext.getKeyStoreFile(KeyStoreFileType.PEM).getAbsolutePath(), null, KeyStoreFileType.PEM.getPropertyValue()); }
@Test public void testLoadJKSKeyStoreNullPassword() throws Exception { if (!x509TestContext.getKeyStorePassword().isEmpty()) { return; } // Make sure that empty password and null password are treated the same X509KeyManager km = X509Util.createKeyManager( x509TestContext.getKeyStoreFile(KeyStoreFileType.JKS).getAbsolutePath(), null, KeyStoreFileType.JKS.getPropertyValue()); }
@Test public void testLoadPEMKeyStoreAutodetectStoreFileType() throws Exception { // Make sure we can instantiate a key manager from the PEM file on disk X509KeyManager km = X509Util.createKeyManager( x509TestContext.getKeyStoreFile(KeyStoreFileType.PEM).getAbsolutePath(), x509TestContext.getKeyStorePassword(), null /* null StoreFileType means 'autodetect from file extension' */); }
@Test(expected = X509Exception.KeyManagerException.class) public void testLoadPEMKeyStoreWithWrongPassword() throws Exception { // Attempting to load with the wrong key password should fail X509KeyManager km = X509Util.createKeyManager( x509TestContext.getKeyStoreFile(KeyStoreFileType.PEM).getAbsolutePath(), "wrong password", // intentionally use the wrong password KeyStoreFileType.PEM.getPropertyValue()); }
@Test public void testLoadJKSKeyStore() throws Exception { // Make sure we can instantiate a key manager from the JKS file on disk X509KeyManager km = X509Util.createKeyManager( x509TestContext.getKeyStoreFile(KeyStoreFileType.JKS).getAbsolutePath(), x509TestContext.getKeyStorePassword(), KeyStoreFileType.JKS.getPropertyValue()); }
@Test public void testLoadPEMKeyStore() throws Exception { // Make sure we can instantiate a key manager from the PEM file on disk X509KeyManager km = X509Util.createKeyManager( x509TestContext.getKeyStoreFile(KeyStoreFileType.PEM).getAbsolutePath(), x509TestContext.getKeyStorePassword(), KeyStoreFileType.PEM.getPropertyValue()); }
} else { try { km = X509Util.createKeyManager(keyStoreLocation, keyStorePassword, keyStoreTypeProp); } catch (KeyManagerException e) { LOG.error("Failed to create key manager", e);
try { keyManagers = new KeyManager[]{ createKeyManager(keyStoreLocationProp, keyStorePasswordProp, keyStoreTypeProp)}; } catch (KeyManagerException keyManagerException) { throw new SSLContextException("Failed to create KeyManager", keyManagerException);