summaryrefslogtreecommitdiff
path: root/keystore/java/android/security/KeyChain.java
diff options
context:
space:
mode:
authorRobin Lee <rgl@google.com>2015-12-21 12:06:04 +0000
committerRobin Lee <rgl@google.com>2015-12-21 12:09:20 +0000
commit3a435f03906778677b846baa7ebedadd3119e892 (patch)
tree807910c15ddf77dccd9bc713112725169284833a /keystore/java/android/security/KeyChain.java
parent026688070c8002911dc0a8f1fb487bf5bfed52d4 (diff)
Return null on getPrivateKey failure not exception
According to documentation: Returns the {@code PrivateKey} for the requested alias, or null if there is no result. @throws KeyChainException if the alias was valid but there was some problem accessing it. @throws IllegalStateException if called from the main thread. In this case the alias doesn't exist or isn't visible to the caller so they should get null back instead of KeyChainException. Change-Id: Ied5603ac6aefbcef79050f24c2aa7ee8f386be0b
Diffstat (limited to 'keystore/java/android/security/KeyChain.java')
-rw-r--r--keystore/java/android/security/KeyChain.java4
1 files changed, 2 insertions, 2 deletions
diff --git a/keystore/java/android/security/KeyChain.java b/keystore/java/android/security/KeyChain.java
index 40fb0d3750a8..7adad8a4b86e 100644
--- a/keystore/java/android/security/KeyChain.java
+++ b/keystore/java/android/security/KeyChain.java
@@ -350,7 +350,7 @@ public final class KeyChain {
/**
* Returns the {@code PrivateKey} for the requested alias, or null
- * if no there is no result.
+ * if there is no result.
*
* <p> This method may block while waiting for a connection to another process, and must never
* be called from the main thread.
@@ -371,7 +371,7 @@ public final class KeyChain {
final IKeyChainService keyChainService = keyChainConnection.getService();
final String keyId = keyChainService.requestPrivateKey(alias);
if (keyId == null) {
- throw new KeyChainException("keystore had a problem");
+ return null;
}
return AndroidKeyStoreProvider.loadAndroidKeyStorePrivateKeyFromKeystore(
KeyStore.getInstance(), keyId, KeyStore.UID_SELF);