Avoid NPE if the keystore does not contain the given alias
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/8c8ed166 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/8c8ed166 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/8c8ed166 Branch: refs/heads/master Commit: 8c8ed16605a2d7468da380155e9aa4c4bbd62031 Parents: e4feffb Author: Colm O hEigeartaigh <[email protected]> Authored: Tue Apr 21 14:48:50 2015 +0100 Committer: Colm O hEigeartaigh <[email protected]> Committed: Tue Apr 21 15:20:29 2015 +0100 ---------------------------------------------------------------------- .../main/java/org/apache/cxf/common/util/crypto/CryptoUtils.java | 3 +++ 1 file changed, 3 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/8c8ed166/core/src/main/java/org/apache/cxf/common/util/crypto/CryptoUtils.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/cxf/common/util/crypto/CryptoUtils.java b/core/src/main/java/org/apache/cxf/common/util/crypto/CryptoUtils.java index 1b732e5..5495fbc 100644 --- a/core/src/main/java/org/apache/cxf/common/util/crypto/CryptoUtils.java +++ b/core/src/main/java/org/apache/cxf/common/util/crypto/CryptoUtils.java @@ -637,6 +637,9 @@ public final class CryptoUtils { } public static Certificate loadCertificate(KeyStore keyStore, String alias) { try { + if (!keyStore.containsAlias(alias)) { + throw new SecurityException("No alias exists in the keystore for the given alias: " + alias); + } return keyStore.getCertificate(alias); } catch (Exception ex) { throw new SecurityException(ex);
