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

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

Issue 144153002: Follow-up changes to Android certificate verification logic. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove sInitialized logic. Created 6 years, 11 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 | net/android/network_library.cc » ('j') | tools/metrics/histograms/histograms.xml » ('J')
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 788f226b922a54e5f41eda91e6cbe9ec1aa8191a..18ab61333d56802f4151c0d1165a9125b15f27cd 100644
--- a/net/android/java/src/org/chromium/net/X509Util.java
+++ b/net/android/java/src/org/chromium/net/X509Util.java
@@ -157,7 +157,7 @@ public class X509Util {
private static final Object sLock = new Object();
/*
- * Allow disabling registering the observer for the certificat changes. Net unit tests do not
+ * Allow disabling registering the observer for the certificate changes. Net unit tests do not
* load native libraries which prevent this to succeed. Moreover, the system does not allow to
* interact with the certificate store without user interaction.
*/
@@ -176,7 +176,14 @@ public class X509Util {
sDefaultTrustManager = X509Util.createTrustManager(null);
}
if (sSystemTrustRoots == null) {
- sSystemTrustRoots = buildSystemTrustRootSet();
+ try {
+ sSystemTrustRoots = buildSystemTrustRootSet();
+ } catch (KeyStoreException e) {
+ // If the device does not have an "AndroidCAStore" KeyStore, don't make the
+ // failure fatal. Instead default conservatively to setting isIssuedByKnownRoot
+ // to false everywhere.
+ Log.w(TAG, "Could not load system trust root set", e);
+ }
}
if (sTestKeyStore == null) {
sTestKeyStore = KeyStore.getInstance(KeyStore.getDefaultType());
@@ -240,7 +247,7 @@ public class X509Util {
for (TrustManager tm : tmf.getTrustManagers()) {
if (tm instanceof X509TrustManager) {
try {
- if (Build.VERSION.SDK_INT >= 17) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
return new X509TrustManagerJellyBean((X509TrustManager) tm);
} else {
return new X509TrustManagerIceCreamSandwich((X509TrustManager) tm);
@@ -404,13 +411,15 @@ public class X509Util {
}
boolean isIssuedByKnownRoot = false;
- if (verifiedChain.size() > 0) {
+ if (sSystemTrustRoots != null && verifiedChain.size() > 0) {
X509Certificate root = verifiedChain.get(verifiedChain.size() - 1);
isIssuedByKnownRoot = sSystemTrustRoots.contains(
new Pair<X500Principal, PublicKey>(root.getSubjectX500Principal(),
root.getPublicKey()));
}
+ nativeRecordCertVerifyCapabilitiesHistogram(sSystemTrustRoots != null);
+
return new AndroidCertVerifyResult(CertVerifyStatusAndroid.VERIFY_OK,
isIssuedByKnownRoot, verifiedChain);
}
@@ -425,6 +434,12 @@ public class X509Util {
private static native void nativeNotifyKeyChainChanged();
/**
+ * Record histograms on the platform's certificate verification capabilities.
+ */
+ private static native void nativeRecordCertVerifyCapabilitiesHistogram(
+ boolean foundSystemTrustRoots);
+
+ /**
* Returns the application context.
*/
private static native Context nativeGetApplicationContext();
« no previous file with comments | « no previous file | net/android/network_library.cc » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698