Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): Update SSL error handling #1466

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -801,10 +801,23 @@ public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request

@Override
public void onReceivedSslError(final WebView webView, final SslErrorHandler handler, final SslError error) {
// WebView.getUrl() will return the top-level window URL.
alesandroortiz marked this conversation as resolved.
Show resolved Hide resolved
// If a top-level navigation triggers this error handler, the top-level URL will be the failing URL (not the current URL).
alesandroortiz marked this conversation as resolved.
Show resolved Hide resolved
// This is desired behavior. We later use these values to determine whether the request is a top-level navigation or a subresource request.
String topWindowUrl = webView.getUrl();
String failingUrl = error.getUrl();

// Cancel request after obtaining top-level URL.
// If request is cancelled before obtaining top-level URL, undesired behavior may occur.
// Undesired behavior: Return value of WebView.getUrl() may be the current URL instead of the failing URL.
handler.cancel();

if (!topWindowUrl.equalsIgnoreCase(failingUrl)) {
// If error is not due to top-level navigation, then do not call onReceivedError()
return;
alesandroortiz marked this conversation as resolved.
Show resolved Hide resolved
}

int code = error.getPrimaryError();
String failingUrl = error.getUrl();
String description = "";
String descriptionPrefix = "SSL error: ";

Expand Down