When falling back to cacerts (or jssecacerts), default to "jks"
@@ -99,7 +99,7 @@ protected void engineInit(KeyStore ks)
{
if (ks == null)
{
- ks = createTrustStore();
+ String defaultType = KeyStore.getDefaultType();
String tsPath = null;
char[] tsPassword = null;
@@ -120,13 +120,17 @@ protected void engineInit(KeyStore ks)
}
else if (new File(JSSECACERTS_PATH).exists())
{
+ defaultType = "jks";
tsPath = JSSECACERTS_PATH;
}
else if (new File(CACERTS_PATH).exists())
{
+ defaultType = "jks";
tsPath = CACERTS_PATH;
}
+ ks = createTrustStore(defaultType);
+
if (tsPath == null)
{
ks.load(null, null);
@@ -184,21 +188,21 @@ protected void engineInit(ManagerFactoryParameters spec)
}
}
- private String getTrustStoreType()
+ private String getTrustStoreType(String defaultType)
{
String tsType = PropertyUtils.getSystemProperty("javax.net.ssl.trustStoreType");
if (tsType == null)
{
- tsType = KeyStore.getDefaultType();
+ tsType = defaultType;
}
return tsType;
}
- private KeyStore createTrustStore()
+ private KeyStore createTrustStore(String defaultType)
throws NoSuchProviderException, KeyStoreException
{
- String tsType = getTrustStoreType();
+ String tsType = getTrustStoreType(defaultType);
String tsProv = PropertyUtils.getSystemProperty("javax.net.ssl.trustStoreProvider");
KeyStore ts = (tsProv == null || tsProv.length() < 1)
? KeyStore.getInstance(tsType)
