@Test public void testGetPropertyValue() { Assert.assertEquals("PEM", KeyStoreFileType.PEM.getPropertyValue()); Assert.assertEquals("JKS", KeyStoreFileType.JKS.getPropertyValue()); }
@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(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 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(expected = X509Exception.TrustManagerException.class) public void testLoadJKSTrustStoreWithWrongPassword() throws Exception { // Attempting to load with the wrong key password should fail X509TrustManager tm = X509Util.createTrustManager( x509TestContext.getTrustStoreFile(KeyStoreFileType.JKS).getAbsolutePath(), "wrong password", KeyStoreFileType.JKS.getPropertyValue(), true, true, true, true); }
@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 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 testLoadPEMTrustStoreNullPassword() throws Exception { if (!x509TestContext.getTrustStorePassword().isEmpty()) { return; } // Make sure that empty password and null password are treated the same X509TrustManager tm = X509Util.createTrustManager( x509TestContext.getTrustStoreFile(KeyStoreFileType.PEM).getAbsolutePath(), null, KeyStoreFileType.PEM.getPropertyValue(), false, false, true, true); }
@Test public void testLoadJKSTrustStoreNullPassword() throws Exception { if (!x509TestContext.getTrustStorePassword().isEmpty()) { return; } // Make sure that empty password and null password are treated the same X509TrustManager tm = X509Util.createTrustManager( x509TestContext.getTrustStoreFile(KeyStoreFileType.JKS).getAbsolutePath(), null, KeyStoreFileType.JKS.getPropertyValue(), false, false, true, true); }
@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()); }
@Test public void testLoadPEMTrustStore() throws Exception { // Make sure we can instantiate a trust manager from the PEM file on disk X509TrustManager tm = X509Util.createTrustManager( x509TestContext.getTrustStoreFile(KeyStoreFileType.PEM).getAbsolutePath(), x509TestContext.getTrustStorePassword(), KeyStoreFileType.PEM.getPropertyValue(), false, false, true, true); }
@Test public void testLoadJKSTrustStore() throws Exception { // Make sure we can instantiate a trust manager from the JKS file on disk X509TrustManager tm = X509Util.createTrustManager( x509TestContext.getTrustStoreFile(KeyStoreFileType.JKS).getAbsolutePath(), x509TestContext.getTrustStorePassword(), KeyStoreFileType.JKS.getPropertyValue(), true, true, true, true); }
this.getKeyStoreFile(keyStoreFileType).getAbsolutePath()); System.setProperty(x509Util.getSslKeystorePasswdProperty(), this.getKeyStorePassword()); System.setProperty(x509Util.getSslKeystoreTypeProperty(), keyStoreFileType.getPropertyValue()); System.setProperty( x509Util.getSslTruststoreLocationProperty(), this.getTrustStoreFile(trustStoreFileType).getAbsolutePath()); System.setProperty(x509Util.getSslTruststorePasswdProperty(), this.getTrustStorePassword()); System.setProperty(x509Util.getSslTruststoreTypeProperty(), trustStoreFileType.getPropertyValue()); if (hostnameVerification != null) { System.setProperty(x509Util.getSslHostnameVerificationEnabledProperty(), hostnameVerification.toString());