Index: net/android/java/src/org/chromium/net/DefaultAndroidKeyStore.java |
diff --git a/net/android/java/src/org/chromium/net/DefaultAndroidKeyStore.java b/net/android/java/src/org/chromium/net/DefaultAndroidKeyStore.java |
index cc6165772c1d29787e842371cdac75103480aa3c..2492da6befc35b8f761bb463d550a62f08493ae2 100644 |
--- a/net/android/java/src/org/chromium/net/DefaultAndroidKeyStore.java |
+++ b/net/android/java/src/org/chromium/net/DefaultAndroidKeyStore.java |
@@ -167,7 +167,7 @@ public class DefaultAndroidKeyStore implements AndroidKeyStore { |
Log.e(TAG, "Cannot find system OpenSSLRSAPrivateKey class: " + e); |
return 0; |
} |
- if (!superClass.isInstance(key)) { |
+ if (!superClass.isInstance(javaKey)) { |
// This may happen if the PrivateKey was not created by the "AndroidOpenSSL" |
// provider, which should be the default. That could happen if an OEM decided |
// to implement a different default provider. Also highly unlikely. |
@@ -197,7 +197,11 @@ public class DefaultAndroidKeyStore implements AndroidKeyStore { |
// Use reflection to invoke the 'getPkeyContext' method on the |
// result of the getOpenSSLKey(). This is an 32-bit integer |
- // which is the address of an EVP_PKEY object. |
+ // which is the address of an EVP_PKEY object. Note that this |
+ // method these days returns a 64-bit long, but since this code |
+ // path is used for older Android versions, it may still return |
+ // a 32-bit int here. To be on the safe side, we cast the return |
+ // value via Number rather than directly to Integer or Long. |
Method getPkeyContext; |
try { |
getPkeyContext = opensslKey.getClass().getDeclaredMethod("getPkeyContext"); |
@@ -209,7 +213,7 @@ public class DefaultAndroidKeyStore implements AndroidKeyStore { |
getPkeyContext.setAccessible(true); |
long evp_pkey = 0; |
try { |
- evp_pkey = (Long) getPkeyContext.invoke(opensslKey); |
+ evp_pkey = ((Number) getPkeyContext.invoke(opensslKey)).longValue(); |
} finally { |
getPkeyContext.setAccessible(false); |
} |