| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.net; | 5 package org.chromium.net; |
| 6 | 6 |
| 7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.content.BroadcastReceiver; | 8 import android.content.BroadcastReceiver; |
| 9 import android.content.Context; | 9 import android.content.Context; |
| 10 import android.content.Intent; | 10 import android.content.Intent; |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 sSystemKeyStore.load(null); | 196 sSystemKeyStore.load(null); |
| 197 } catch (IOException e) { | 197 } catch (IOException e) { |
| 198 // No IO operation is attempted. | 198 // No IO operation is attempted. |
| 199 } | 199 } |
| 200 sSystemCertificateDirectory = | 200 sSystemCertificateDirectory = |
| 201 new File(System.getenv("ANDROID_ROOT") + "/etc/secur
ity/cacerts"); | 201 new File(System.getenv("ANDROID_ROOT") + "/etc/secur
ity/cacerts"); |
| 202 } catch (KeyStoreException e) { | 202 } catch (KeyStoreException e) { |
| 203 // Could not load AndroidCAStore. Continue anyway; isKnownRo
ot will always | 203 // Could not load AndroidCAStore. Continue anyway; isKnownRo
ot will always |
| 204 // return false. | 204 // return false. |
| 205 } | 205 } |
| 206 if (!sDisableNativeCodeForTest) | 206 if (!sDisableNativeCodeForTest) { |
| 207 nativeRecordCertVerifyCapabilitiesHistogram(sSystemKeyStore
!= null); | 207 nativeRecordCertVerifyCapabilitiesHistogram(sSystemKeyStore
!= null); |
| 208 } |
| 208 sLoadedSystemKeyStore = true; | 209 sLoadedSystemKeyStore = true; |
| 209 } | 210 } |
| 210 if (sSystemTrustAnchorCache == null) { | 211 if (sSystemTrustAnchorCache == null) { |
| 211 sSystemTrustAnchorCache = new HashSet<Pair<X500Principal, Public
Key>>(); | 212 sSystemTrustAnchorCache = new HashSet<Pair<X500Principal, Public
Key>>(); |
| 212 } | 213 } |
| 213 if (sTestKeyStore == null) { | 214 if (sTestKeyStore == null) { |
| 214 sTestKeyStore = KeyStore.getInstance(KeyStore.getDefaultType()); | 215 sTestKeyStore = KeyStore.getInstance(KeyStore.getDefaultType()); |
| 215 try { | 216 try { |
| 216 sTestKeyStore.load(null); | 217 sTestKeyStore.load(null); |
| 217 } catch (IOException e) { | 218 } catch (IOException e) { |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 } catch (CertificateExpiredException e) { | 455 } catch (CertificateExpiredException e) { |
| 455 return new AndroidCertVerifyResult(CertVerifyStatusAndroid.EXPIRED); | 456 return new AndroidCertVerifyResult(CertVerifyStatusAndroid.EXPIRED); |
| 456 } catch (CertificateNotYetValidException e) { | 457 } catch (CertificateNotYetValidException e) { |
| 457 return new AndroidCertVerifyResult(CertVerifyStatusAndroid.NOT_YET_V
ALID); | 458 return new AndroidCertVerifyResult(CertVerifyStatusAndroid.NOT_YET_V
ALID); |
| 458 } catch (CertificateException e) { | 459 } catch (CertificateException e) { |
| 459 return new AndroidCertVerifyResult(CertVerifyStatusAndroid.FAILED); | 460 return new AndroidCertVerifyResult(CertVerifyStatusAndroid.FAILED); |
| 460 } | 461 } |
| 461 | 462 |
| 462 synchronized (sLock) { | 463 synchronized (sLock) { |
| 463 // If no trust manager was found, fail without crashing on the null
pointer. | 464 // If no trust manager was found, fail without crashing on the null
pointer. |
| 464 if (sDefaultTrustManager == null) | 465 if (sDefaultTrustManager == null) { |
| 465 return new AndroidCertVerifyResult(CertVerifyStatusAndroid.FAILE
D); | 466 return new AndroidCertVerifyResult(CertVerifyStatusAndroid.FAILE
D); |
| 467 } |
| 466 | 468 |
| 467 List<X509Certificate> verifiedChain; | 469 List<X509Certificate> verifiedChain; |
| 468 try { | 470 try { |
| 469 verifiedChain = sDefaultTrustManager.checkServerTrusted(serverCe
rtificates, | 471 verifiedChain = sDefaultTrustManager.checkServerTrusted(serverCe
rtificates, |
| 470 authType
, host); | 472 authType
, host); |
| 471 } catch (CertificateException eDefaultManager) { | 473 } catch (CertificateException eDefaultManager) { |
| 472 try { | 474 try { |
| 473 verifiedChain = sTestTrustManager.checkServerTrusted(serverC
ertificates, | 475 verifiedChain = sTestTrustManager.checkServerTrusted(serverC
ertificates, |
| 474 authTyp
e, host); | 476 authTyp
e, host); |
| 475 } catch (CertificateException eTestManager) { | 477 } catch (CertificateException eTestManager) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 506 */ | 508 */ |
| 507 private static native void nativeRecordCertVerifyCapabilitiesHistogram( | 509 private static native void nativeRecordCertVerifyCapabilitiesHistogram( |
| 508 boolean foundSystemTrustRoots); | 510 boolean foundSystemTrustRoots); |
| 509 | 511 |
| 510 /** | 512 /** |
| 511 * Returns the application context. | 513 * Returns the application context. |
| 512 */ | 514 */ |
| 513 private static native Context nativeGetApplicationContext(); | 515 private static native Context nativeGetApplicationContext(); |
| 514 | 516 |
| 515 } | 517 } |
| OLD | NEW |