summaryrefslogtreecommitdiffstats
path: root/android_webview/java
diff options
context:
space:
mode:
authorcramya@chromium.org <cramya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-05 01:42:51 +0000
committercramya@chromium.org <cramya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-05 01:42:51 +0000
commit3c230b138665a58b4862549569af19bde12dbcfa (patch)
tree66535f94cbd253c0a97f77774b4795624833af68 /android_webview/java
parente7d4b8a9cf9f4a67e6ba04e2cabf9a6161449b1a (diff)
downloadchromium_src-3c230b138665a58b4862549569af19bde12dbcfa.zip
chromium_src-3c230b138665a58b4862549569af19bde12dbcfa.tar.gz
chromium_src-3c230b138665a58b4862549569af19bde12dbcfa.tar.bz2
Upstream AwContents.GetCertificate()
BUG=crbug.com/145999 Review URL: https://chromiumcodereview.appspot.com/11054019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160291 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview/java')
-rw-r--r--android_webview/java/src/org/chromium/android_webview/AwContents.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java
index f5f426e..8bbf6ab 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -4,6 +4,7 @@
package org.chromium.android_webview;
+import android.net.http.SslCertificate;
import android.os.AsyncTask;
import android.os.Message;
import android.text.TextUtils;
@@ -17,11 +18,16 @@ import org.chromium.base.ThreadUtils;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.NavigationHistory;
import org.chromium.content.common.CleanupReference;
+import org.chromium.net.X509Util;
import org.chromium.ui.gfx.NativeWindow;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
/**
* Exposes the native AwContents class, and together these classes wrap the ContentViewCore
@@ -206,6 +212,35 @@ public class AwContents {
.setHttpAuthUsernamePassword(host, realm, username, password);
}
+ /**
+ * @see android.webkit.WebView#getCertificate()
+ */
+ public SslCertificate getCertificate() {
+ byte[] derBytes = nativeGetCertificate(mNativeAwContents);
+ if (derBytes == null) {
+ return null;
+ }
+
+ try {
+ X509Certificate x509Certificate =
+ X509Util.createCertificateFromBytes(derBytes);
+ return new SslCertificate(x509Certificate);
+ } catch (CertificateException e) {
+ // Intentional fall through
+ // A SSL related exception must have occured. This shouldn't happen.
+ Log.w(TAG, "Could not read certificate: " + e);
+ } catch (KeyStoreException e) {
+ // Intentional fall through
+ // A SSL related exception must have occured. This shouldn't happen.
+ Log.w(TAG, "Could not read certificate: " + e);
+ } catch (NoSuchAlgorithmException e) {
+ // Intentional fall through
+ // A SSL related exception must have occured. This shouldn't happen.
+ Log.w(TAG, "Could not read certificate: " + e);
+ }
+ return null;
+ }
+
//--------------------------------------------------------------------------------------------
// Methods called from native via JNI
//--------------------------------------------------------------------------------------------
@@ -329,4 +364,5 @@ public class AwContents {
private native void nativeFindNext(int nativeAwContents, boolean forward);
private native void nativeClearMatches(int nativeAwContents);
private native void nativeClearCache(int nativeAwContents, boolean includeDiskFiles);
+ private native byte[] nativeGetCertificate(int nativeAwContents);
}