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

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

Issue 12212135: Return specific cert verification errors on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 7 years, 10 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
Index: net/android/java/src/org/chromium/net/AndroidNetworkLibrary.java
diff --git a/net/android/java/src/org/chromium/net/AndroidNetworkLibrary.java b/net/android/java/src/org/chromium/net/AndroidNetworkLibrary.java
index 69a5722d2445638df00e73771722292d51e47495..a0756852ae0ed0fd6c14dfdd14488c3035faa76f 100644
--- a/net/android/java/src/org/chromium/net/AndroidNetworkLibrary.java
+++ b/net/android/java/src/org/chromium/net/AndroidNetworkLibrary.java
@@ -10,9 +10,10 @@ import android.content.Intent;
import android.security.KeyChain;
import android.util.Log;
-import org.chromium.net.CertificateMimeType;
import org.chromium.base.CalledByNative;
import org.chromium.base.CalledByNativeUnchecked;
+import org.chromium.net.CertVerifyResultAndroid;
+import org.chromium.net.CertificateMimeType;
import java.net.Inet6Address;
import java.net.InetAddress;
@@ -66,7 +67,7 @@ class AndroidNetworkLibrary {
* PKCS#12 keychain) through the system's CertInstaller activity.
*
* @param context: current application context.
- * @param file_type: cryptographic file type. E.g. CertificateMimeType.X509_USER_CERT
+ * @param cert_type: cryptographic file type. E.g. CertificateMimeType.X509_USER_CERT
* @param data: certificate/keychain data bytes.
* @return true on success, false on failure.
*
@@ -196,15 +197,17 @@ class AndroidNetworkLibrary {
*
* @param certChain The ASN.1 DER encoded bytes for certificates.
* @param authType The key exchange algorithm name (e.g. RSA)
- * @return true if the server is trusted
- * @throws CertificateException,KeyStoreException,NoSuchAlgorithmException
- * on error initializing the TrustManager or reading the
- * certChain
+ * @return Android certificate verification result code.
*/
- @CalledByNativeUnchecked
- public static boolean verifyServerCertificates(byte[][] certChain, String authType)
- throws CertificateException, KeyStoreException, NoSuchAlgorithmException {
- return X509Util.verifyServerCertificates(certChain, authType);
+ @CalledByNative
+ public static int verifyServerCertificates(byte[][] certChain, String authType) {
+ try {
+ return X509Util.verifyServerCertificates(certChain, authType);
+ } catch (KeyStoreException e) {
+ return CertVerifyResultAndroid.VERIFY_FAILED;
+ } catch (NoSuchAlgorithmException e) {
+ return CertVerifyResultAndroid.VERIFY_FAILED;
+ }
}
/**
@@ -226,4 +229,4 @@ class AndroidNetworkLibrary {
CertificateException, KeyStoreException {
X509Util.clearTestRootCertificates();
}
-}
+}
« no previous file with comments | « net/android/java/CertVerifyResultAndroid.template ('k') | net/android/java/src/org/chromium/net/X509Util.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698