From c87b714a46f83bace2bb5840acfa6c26fa866044 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Tue, 10 Oct 2017 16:52:06 +0200 Subject: [PATCH] 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. --- .../jetty/util/ssl/SslContextFactory.java | 2 +- .../jetty/util/ssl/SslContextFactoryTest.java | 18 ++++++++++++++++++ jetty-util/src/test/resources/keystore.jce | Bin 0 -> 2209 bytes jetty-util/src/test/resources/keystore.p12 | Bin 0 -> 2533 bytes 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 jetty-util/src/test/resources/keystore.jce create mode 100644 jetty-util/src/test/resources/keystore.p12 diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java b/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java index 7d7647c89b4..70b61574e3e 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java @@ -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; diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java index d394300b6ff..da5b9f8ef99 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java @@ -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(); + } } diff --git a/jetty-util/src/test/resources/keystore.jce b/jetty-util/src/test/resources/keystore.jce new file mode 100644 index 0000000000000000000000000000000000000000..e5d614492ae4ad4b424c28c1ab14d38df62fb7e7 GIT binary patch literal 2209 zcmchX`8U*y8^>qH%w!B>8Ih5MP-D5DLH2!X?8%xX8DyAT3}Q?oOQulCAcnC;G2v^E z7Ln`}5^e}LdxoZkOgC5G<(&H$e9v>t@bEAQ1cK}f{BOZRD5L<& zKKa0#-#UXp(2qbObOpe`5lV0{6pV$S!GHji7Z`Z-c97E40s)Ic6QRAc+!Q{f2rjT? zlzJ%o*p7lp$6WQZ@eYrmZSs(fBcnLWv1|LA*wN-rsS}X$-V$9aNB=b!HAA(Z?d_jN zDjADrJ4FU3SIvZ|zJ-sQjU@j_-?iVYqxK|!J58eshi;4zL8_twDTH$6yt4Wd`R8_R z9zlV~_&m(>?V+Ls)W5#S4NG$@Z1cUUTYKqUEfNkNPxyBz(r4`Z{W7WLnsu~=PvvoN zj6dNJMZXkluBe8WFaDFc;<(>EAJk#g=$-7xgHFc96(5L0%`}=H=lYWO|JNR#0WqS{~NlkGFJ-eRg<`sS@tzqwHhk_aVxQH$Fz8 zK`y72suZg9;1Yc&h;?UyV4!8D5pW(eW)$O0Rt{w?=oA zOcl4xl`42JKNdr@QvR$Jz&;~z_A8-JCapW}i zNz_u$Z2OWWcRf8nnodyRp?9R;7cHx2t$XSBR9n2l*L-rG)*D}ws~yGbX}4%uw#DH`U^|`WC$6*r%avh;T3SMOiLF)Dk<9X3*&cvb&;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