Java Code Examples for android.webkit.SslErrorHandler#cancel()

The following examples show how to use android.webkit.SslErrorHandler#cancel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FocusWebViewClient.java    From firefox-echo-show with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    handler.cancel();

    // WebView can try to load the favicon for a bad page when you set a new URL. If we then
    // loadErrorPage() again, WebView tries to load the favicon again. We end up in onReceivedSSlError()
    // again, and we get an infinite loop of reloads (we also erroneously show the favicon URL
    // in the toolbar, but that's less noticeable). Hence we check whether this error is from
    // the desired page, or a page resource:
    if (error.getUrl().equals(currentPageURL)) {
        TelemetryWrapper.sslErrorEvent(true, error);
        ErrorPage.loadErrorPage(view, error.getUrl(), WebViewClient.ERROR_FAILED_SSL_HANDSHAKE);
    } else {
        TelemetryWrapper.sslErrorEvent(false, error);
    }
}
 
Example 2
Source File: FocusWebViewClient.java    From focus-android with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    handler.cancel();

    if (callback != null) {
        callback.onSecurityChanged(error.getCertificate() != null, null, (error.getCertificate() != null) ? error.getCertificate().getIssuedBy().getOName() : null);
    }
    // WebView can try to load the favicon for a bad page when you set a new URL. If we then
    // loadErrorPage() again, WebView tries to load the favicon again. We end up in onReceivedSSlError()
    // again, and we get an infinite loop of reloads (we also erroneously show the favicon URL
    // in the toolbar, but that's less noticeable). Hence we check whether this error is from
    // the desired page, or a page resource:
    if (error.getUrl().equals(currentPageURL)) {
        TelemetryWrapper.sslErrorEvent(true, error);
        ErrorPage.loadErrorPage(view, error.getUrl(), WebViewClient.ERROR_FAILED_SSL_HANDSHAKE);
    } else {
        TelemetryWrapper.sslErrorEvent(false, error);
    }
}
 
Example 3
Source File: WebDialog.java    From aws-mobile-self-paced-labs-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    if (DISABLE_SSL_CHECK_FOR_TESTING) {
        handler.proceed();
    } else {
        super.onReceivedSslError(view, handler, error);

        sendErrorToListener(new FacebookDialogException(null, ERROR_FAILED_SSL_HANDSHAKE, null));
        handler.cancel();
        WebDialog.this.dismiss();
    }
}
 
Example 4
Source File: WebViewFragment.java    From arcusandroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    Date today = new Date();
    today.setTime(System.currentTimeMillis());
    if(error.getPrimaryError() == SslError.SSL_DATE_INVALID ||
            error.getPrimaryError() == SslError.SSL_IDMISMATCH ||
            error.getPrimaryError() == SslError.SSL_INVALID ||
            error.getPrimaryError() == SslError.SSL_UNTRUSTED) {
        handler.cancel();
    }
    else {
        handler.proceed();
    }
}
 
Example 5
Source File: WebDialog.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    if (DISABLE_SSL_CHECK_FOR_TESTING) {
        handler.proceed();
    } else {
        super.onReceivedSslError(view, handler, error);

        sendErrorToListener(new FacebookDialogException(null, ERROR_FAILED_SSL_HANDSHAKE, null));
        handler.cancel();
        WebDialog.this.dismiss();
    }
}
 
Example 6
Source File: WebDialog.java    From android-skeleton-project with MIT License 5 votes vote down vote up
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    if (DISABLE_SSL_CHECK_FOR_TESTING) {
        handler.proceed();
    } else {
        super.onReceivedSslError(view, handler, error);

        sendErrorToListener(new FacebookDialogException(null, ERROR_FAILED_SSL_HANDSHAKE, null));
        handler.cancel();
        WebDialog.this.dismiss();
    }
}
 
Example 7
Source File: WebDialog.java    From KlyphMessenger with MIT License 5 votes vote down vote up
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    if (DISABLE_SSL_CHECK_FOR_TESTING) {
        handler.proceed();
    } else {
        super.onReceivedSslError(view, handler, error);

        sendErrorToListener(new FacebookDialogException(null, ERROR_FAILED_SSL_HANDSHAKE, null));
        handler.cancel();
        WebDialog.this.dismiss();
    }
}
 
Example 8
Source File: WebGuiActivity.java    From syncthing-android with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Catch (self-signed) SSL errors and test if they correspond to Syncthing's certificate.
 */
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    try {
        int sdk = android.os.Build.VERSION.SDK_INT;
        if (sdk < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            // The mX509Certificate field is not available for ICS- devices
            Log.w(TAG, "Skipping certificate check for devices <ICS");
            handler.proceed();
            return;
        }
        // Use reflection to access the private mX509Certificate field of SslCertificate
        SslCertificate sslCert = error.getCertificate();
        Field f = sslCert.getClass().getDeclaredField("mX509Certificate");
        f.setAccessible(true);
        X509Certificate cert = (X509Certificate)f.get(sslCert);
        if (cert == null) {
            Log.w(TAG, "X509Certificate reference invalid");
            handler.cancel();
            return;
        }
        cert.verify(mCaCert.getPublicKey());
        handler.proceed();
    } catch (NoSuchFieldException|IllegalAccessException|CertificateException|
            NoSuchAlgorithmException|InvalidKeyException|NoSuchProviderException|
            SignatureException e) {
        Log.w(TAG, e);
        handler.cancel();
    }
}
 
Example 9
Source File: WebDialog.java    From Klyph with MIT License 5 votes vote down vote up
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    if (DISABLE_SSL_CHECK_FOR_TESTING) {
        handler.proceed();
    } else {
        super.onReceivedSslError(view, handler, error);

        sendErrorToListener(new FacebookDialogException(null, ERROR_FAILED_SSL_HANDSHAKE, null));
        handler.cancel();
        WebDialog.this.dismiss();
    }
}
 
Example 10
Source File: WebDialog.java    From facebooklogin with MIT License 5 votes vote down vote up
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    if (DISABLE_SSL_CHECK_FOR_TESTING) {
        handler.proceed();
    } else {
        super.onReceivedSslError(view, handler, error);

        sendErrorToListener(new FacebookDialogException(null,
                                                        ERROR_FAILED_SSL_HANDSHAKE,
                                                        null));
        handler.cancel();
        WebDialog.this.dismiss();
    }
}
 
Example 11
Source File: WebDialog.java    From platform-friends-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    if (DISABLE_SSL_CHECK_FOR_TESTING) {
        handler.proceed();
    } else {
        super.onReceivedSslError(view, handler, error);

        sendErrorToListener(new FacebookDialogException(null, ERROR_FAILED_SSL_HANDSHAKE, null));
        handler.cancel();
        WebDialog.this.dismiss();
    }
}
 
Example 12
Source File: WebDialog.java    From Abelana-Android with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    if (DISABLE_SSL_CHECK_FOR_TESTING) {
        handler.proceed();
    } else {
        super.onReceivedSslError(view, handler, error);

        sendErrorToListener(new FacebookDialogException(null, ERROR_FAILED_SSL_HANDSHAKE, null));
        handler.cancel();
        WebDialog.this.dismiss();
    }
}
 
Example 13
Source File: KakaoWebViewDialog.java    From kakao-android-sdk-standalone with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    super.onReceivedSslError(view, handler, error);

    sendErrorToListener(new KakaoWebviewException(ERROR_FAILED_SSL_HANDSHAKE, null, null));
    handler.cancel();
    dismiss();
}
 
Example 14
Source File: LetvOpenIDOAuthLoginActivity.java    From letv with Apache License 2.0 5 votes vote down vote up
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    if (LetvOpenIDOAuthLoginActivity.this.baseUrl.contains(LetvUtils.WEB_INNER_FLAG) || !LetvConfig.getPcode().equals("010110016")) {
        handler.proceed();
    } else {
        handler.cancel();
    }
}
 
Example 15
Source File: HongKongLoginWebview.java    From letv with Apache License 2.0 5 votes vote down vote up
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    if (HongKongLoginWebview.this.baseUrl.contains(LetvUtils.WEB_INNER_FLAG) || !LetvConfig.getPcode().equals("010110016")) {
        handler.proceed();
    } else {
        handler.cancel();
    }
}
 
Example 16
Source File: LetvWebViewActivity.java    From letv with Apache License 2.0 5 votes vote down vote up
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    LogInfo.log("LM", "onReceivedSslError");
    if (LetvWebViewActivity.this.baseUrl.contains(LetvUtils.WEB_INNER_FLAG) || !LetvConfig.getPcode().equals("010110016")) {
        handler.proceed();
    } else {
        handler.cancel();
    }
}
 
Example 17
Source File: WebDialog.java    From kognitivo with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    if (DISABLE_SSL_CHECK_FOR_TESTING) {
        handler.proceed();
    } else {
        super.onReceivedSslError(view, handler, error);

        handler.cancel();
        sendErrorToListener(new FacebookDialogException(null, ERROR_FAILED_SSL_HANDSHAKE, null));
    }
}
 
Example 18
Source File: WebViewActivity.java    From SteamGifts with MIT License 4 votes vote down vote up
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    Toast.makeText(WebViewActivity.this, "Invalid SSL Certificate.", Toast.LENGTH_SHORT).show();

    handler.cancel();
}
 
Example 19
Source File: AuthDialog.java    From letv with Apache License 2.0 4 votes vote down vote up
@TargetApi(8)
public void onReceivedSslError(WebView webView, SslErrorHandler sslErrorHandler, SslError sslError) {
    sslErrorHandler.cancel();
    this.a.c.onError(new UiError(sslError.getPrimaryError(), "请求不合法,请检查手机安全设置,如系统时间、代理等。", "ssl error"));
    this.a.dismiss();
}
 
Example 20
Source File: BaseWebView.java    From dcs-sdk-java with Apache License 2.0 4 votes vote down vote up
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    // 当发生证书认证错误时,采用默认的处理方法handler.cancel(),停止加载问题页面
    handler.cancel();
}