NativeCrypto: not finding a key is not fatal
If we don't find a key in the keystore, we should just return null
reference. The only time we should throw exceptions is when the key
decoding failed or something else like that.
Bug: 20488918
(cherry picked from commit 8098cbbc7fbf2d22402da487465a153734f9f9b6)
Change-Id: I621b39257bc98d888f7ad390fb8648326c67dfc4
diff --git a/src/main/native/org_conscrypt_NativeCrypto.cpp b/src/main/native/org_conscrypt_NativeCrypto.cpp
index 4dc22dc..9590cd6 100644
--- a/src/main/native/org_conscrypt_NativeCrypto.cpp
+++ b/src/main/native/org_conscrypt_NativeCrypto.cpp
@@ -2343,7 +2343,7 @@
#else
Unique_EVP_PKEY pkey(EVP_PKEY_from_keystore(id.c_str()));
if (pkey.get() == NULL) {
- jniThrowRuntimeException(env, "Failed to find named key in keystore");
+ throwExceptionIfNecessary(env, "ENGINE_load_private_key");
return 0;
}
return reinterpret_cast<uintptr_t>(pkey.release());