Fixes #901 - Overriding SSL context KeyStoreType requires explicit override of TrustStoreType.

The default value of _trustStoreType is now null rather than "JKS", so
that existing logic will use the _keyStoreType also for the trust store.
This commit is contained in:
Simone Bordet 2017-10-10 16:52:06 +02:00
parent 2b847405e0
commit c87b714a46
4 changed files with 19 additions and 1 deletions

View File

@ -143,7 +143,7 @@ public class SslContextFactory extends AbstractLifeCycle implements Dumpable
private String _certAlias;
private Resource _trustStoreResource;
private String _trustStoreProvider;
private String _trustStoreType = "JKS";
private String _trustStoreType;
private boolean _needClientAuth = false;
private boolean _wantClientAuth = false;
private Password _keyStorePassword;

View File

@ -278,4 +278,22 @@ public class SslContextFactoryTest
assertFalse(cf.getX509("wild").matches("foo.bar.domain.com"));
assertFalse(cf.getX509("wild").matches("other.com"));
}
@Test
public void testNonDefaultKeyStoreTypeUsedForTrustStore() throws Exception
{
cf = new SslContextFactory();
cf.setKeyStoreResource(Resource.newSystemResource("keystore.p12"));
cf.setKeyStoreType("pkcs12");
cf.setKeyStorePassword("storepwd");
cf.start();
cf.stop();
cf = new SslContextFactory();
cf.setKeyStoreResource(Resource.newSystemResource("keystore.jce"));
cf.setKeyStoreType("jceks");
cf.setKeyStorePassword("storepwd");
cf.start();
cf.stop();
}
}

Binary file not shown.

Binary file not shown.