Java Code Examples for android.net.http.SslError#getUrl()

The following examples show how to use android.net.http.SslError#getUrl() . 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: WebPlayerView.java    From unity-ads-android with Apache License 2.0 6 votes vote down vote up
@TargetApi(14)
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
	// Don't call shouldCallSuper("onReceivedSslError") to ensure
	// we always rely on the default behavior.  Otherwise it is
	// possible Google might reject the app as an unsafe implementation.
	// https://support.google.com/faqs/answer/7071387?hl=en
	super.onReceivedSslError(view, handler, error);
	DeviceLog.error("Received SSL error for '%s': %s", error.getUrl(), error.toString());

	if (shouldSendEvent("onReceivedSslError")) {
		String url = "";
		if (error != null) {
			url = error.getUrl();
		}
		WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.SSL_ERROR, url, viewId);
	}
}
 
Example 2
Source File: WebViewActivity.java    From DeviceConnect-Android with MIT License 6 votes vote down vote up
@Override
public void onReceivedSslError(final WebView view, final SslErrorHandler handler, final SslError error) {
    int primaryError = error.getPrimaryError();
    String url = error.getUrl();
    SslCertificate cert = error.getCertificate();
    mLogger.warning("onReceivedSslError: error = " + primaryError
            + ", url = " + url + ", certificate = " + cert);

    if (primaryError == SslError.SSL_UNTRUSTED && url != null && cert != null) {
        SslCertificate.DName subjectName = cert.getIssuedTo();
        if (subjectName != null
                && "localhost".equals(subjectName.getCName())
                && url.startsWith("https://localhost") ) {
            handler.proceed();
            mLogger.warning("SSL Proceeded: url = " + url);
            return;
        }
    }
    handler.cancel();
    mLogger.severe("SSL Canceled: url = " + url);
}