Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(641)

Unified Diff: net/android/java/src/org/chromium/net/X509Util.java

Issue 316613002: Cleanly return VERIFY_FAILED if no suitable X509TrustManager is found. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/android/java/src/org/chromium/net/X509Util.java
diff --git a/net/android/java/src/org/chromium/net/X509Util.java b/net/android/java/src/org/chromium/net/X509Util.java
index c58346583f7e9eb4b608f2b5b4e39f39f80720f5..934ec40b9257ec36a25d99d2495ef9c7ab72f4e8 100644
--- a/net/android/java/src/org/chromium/net/X509Util.java
+++ b/net/android/java/src/org/chromium/net/X509Util.java
@@ -235,7 +235,7 @@ public class X509Util {
/**
* Creates a X509TrustManagerImplementation backed up by the given key
* store. When null is passed as a key store, system default trust store is
- * used.
+ * used. Returns null if no created TrustManager was suitable.
* @throws KeyStoreException, NoSuchAlgorithmException on error initializing the TrustManager.
*/
private static X509TrustManagerImplementation createTrustManager(KeyStore keyStore) throws
@@ -253,10 +253,12 @@ public class X509Util {
return new X509TrustManagerIceCreamSandwich((X509TrustManager) tm);
}
} catch (IllegalArgumentException e) {
- Log.e(TAG, "Error creating trust manager: " + e);
+ String className = tm.getClass().getName();
+ Log.e(TAG, "Error creating trust manager (" + className + "): " + e);
}
}
}
+ Log.e(TAG, "Could not find suitable trust manager");
return null;
}
@@ -465,6 +467,10 @@ public class X509Util {
}
synchronized (sLock) {
+ // If no trust manager was found, fail without crashing on the null pointer.
+ if (sDefaultTrustManager == null)
+ return new AndroidCertVerifyResult(CertVerifyStatusAndroid.VERIFY_FAILED);
+
List<X509Certificate> verifiedChain;
try {
verifiedChain = sDefaultTrustManager.checkServerTrusted(serverCertificates,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698