Defensive null checks
@@ -400,6 +400,10 @@ private BCX509Key createKeyBC(String keyType, int builderIndex, String localAlia
{
KeyStore.Builder builder = builders.get(builderIndex);
KeyStore keyStore = builder.getKeyStore();
+ if (null == keyStore)
+ {
+ continue;
+ }
for (Enumeration<String> en = keyStore.aliases(); en.hasMoreElements();)
{
@@ -451,6 +455,10 @@ private Match getBestMatch(List<String> keyTypes, Principal[] issuers, Transport
{
KeyStore.Builder builder = builders.get(builderIndex);
KeyStore keyStore = builder.getKeyStore();
+ if (null == keyStore)
+ {
+ continue;
+ }
for (Enumeration<String> en = keyStore.aliases(); en.hasMoreElements();)
{
@@ -587,6 +595,8 @@ private boolean isSuitableChain(X509Certificate[] chain, BCAlgorithmConstraints
String localAlias = alias.substring(localAliasStart, localAliasEnd);
KeyStore keyStore = builder.getKeyStore();
+ if (null != keyStore)
+ {
ProtectionParameter protectionParameter = builder.getProtectionParameter(localAlias);
KeyStore.Entry entry = keyStore.getEntry(localAlias, protectionParameter);
@@ -598,6 +608,7 @@ private boolean isSuitableChain(X509Certificate[] chain, BCAlgorithmConstraints
}
}
}
+ }
catch (Exception e)
{
LOG.log(Level.FINER, "Failed to load PrivateKeyEntry: " + alias, e);
