| Index: android_webview/java/src/org/chromium/android_webview/AwContents.java
|
| 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 4fed78c509bba30c3446391c368ff071bb58dd65..a06e4c0d44bfa1db4f5e7e4282ba59d4b1bff5ac 100644
|
| --- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
|
| +++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
|
| @@ -10,6 +10,7 @@ import android.graphics.Canvas;
|
| import android.graphics.Color;
|
| import android.graphics.Rect;
|
| import android.net.http.SslCertificate;
|
| +import android.net.http.SslError;
|
| import android.os.AsyncTask;
|
| import android.os.Build;
|
| import android.os.Bundle;
|
| @@ -20,6 +21,7 @@ import android.view.MotionEvent;
|
| import android.view.View;
|
| import android.view.ViewGroup;
|
| import android.webkit.GeolocationPermissions;
|
| +import android.webkit.SslErrorHandler;
|
| import android.webkit.ValueCallback;
|
|
|
| import org.chromium.base.CalledByNative;
|
| @@ -583,29 +585,7 @@ public class AwContents {
|
| */
|
| public SslCertificate getCertificate() {
|
| if (mNativeAwContents == 0) return null;
|
| - 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;
|
| + return getCertificateFromDerBytes(nativeGetCertificate(mNativeAwContents));
|
| }
|
|
|
| /**
|
| @@ -840,6 +820,49 @@ public class AwContents {
|
| mContentsClient.onReceivedHttpAuthRequest(handler, host, realm);
|
| }
|
|
|
| + @CalledByNative
|
| + private boolean allowCertificateError(int certError, byte[] derBytes, String url) {
|
| + SslCertificate cert = getCertificateFromDerBytes(derBytes);
|
| + if (cert == null) {
|
| + // if the certificate is null, cancel the request
|
| + return true;
|
| + }
|
| + final SslError sslError = SslError.SslErrorFromChromiumErrorCode(certError, cert, url);
|
| + if (SslCertLookupTable.getInstance().isAllowed(sslError)) {
|
| + proceedSslError(true);
|
| + return false;
|
| + }
|
| +
|
| + SslErrorHandler handler = new SslErrorHandler() {
|
| + @Override
|
| + public void proceed() {
|
| + post(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + SslCertLookupTable.getInstance().setIsAllowed(sslError);
|
| + proceedSslError(true);
|
| + }
|
| + });
|
| + }
|
| + @Override
|
| + public void cancel() {
|
| + post(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + proceedSslError(false);
|
| + }
|
| + });
|
| + }
|
| + };
|
| + mContentsClient.onReceivedSslError(handler, sslError);
|
| + return false;
|
| + }
|
| +
|
| + private void proceedSslError(boolean proceed) {
|
| + if (mNativeAwContents == 0) return;
|
| + nativeProceedSslError(mNativeAwContents, proceed);
|
| + }
|
| +
|
| private static class ChromiumGeolocationCallback implements GeolocationPermissions.Callback {
|
| final int mRenderProcessId;
|
| final int mRenderViewId;
|
| @@ -947,6 +970,31 @@ public class AwContents {
|
| return null;
|
| }
|
|
|
| + private SslCertificate getCertificateFromDerBytes(byte[] derBytes) {
|
| + 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;
|
| + }
|
| +
|
| @CalledByNative
|
| private void handleJsAlert(String url, String message, JsResultReceiver receiver) {
|
| mContentsClient.handleJsAlert(url, message, receiver);
|
| @@ -1000,6 +1048,7 @@ public class AwContents {
|
| private native void nativeClearMatches(int nativeAwContents);
|
| private native void nativeClearCache(int nativeAwContents, boolean includeDiskFiles);
|
| private native byte[] nativeGetCertificate(int nativeAwContents);
|
| + private native void nativeProceedSslError(int nativeAwContents, boolean proceed);
|
| private native void nativeRequestNewHitTestDataAt(int nativeAwContents, int x, int y);
|
| private native void nativeUpdateLastHitTestData(int nativeAwContents);
|
| private native void nativeOnSizeChanged(int nativeAwContents, int w, int h, int ow, int oh);
|
|
|