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

[webview_flutter] handle onWebResourceError in onReceivedSslError on Android #74609

Open
ycherniavskyi opened this issue Jan 24, 2021 · 1 comment
Labels
c: proposal A detailed proposal for a change to Flutter p: webview The WebView plugin P3 Issues that are less important to the Flutter project package flutter/packages repository. See also p: labels. platform-android Android applications specifically team-android Owned by Android platform team triaged-android Triaged by Android platform team

Comments

@ycherniavskyi
Copy link
Contributor

Description

Currently, on Android, there is no possibility to get a notification in Flutter that an SSL error occurred while loading a resource.
The user sees a white screen, and the developer doesn't receive any error callbacks from WebView. Only in log developer can see some error:

[ERROR:ssl_client_socket_impl.cc(962)] handshake failed; returned -1, SSL error code 1, net_error -200

By the way, on iOS, the developer receives onWebResourceError callbacks with an appropriate error.

The reason that Android implementation doesn't implement/provide onReceivedSslError notifier.

My proposal is to left the default behavior of this notifier (call SslErrorHandler#cancel), but handle onWebResourceError callback from WebView, so the developer can see this error and provide some actions.

Related Issues & Pull requests

@pedromassangocode pedromassangocode added p: first party p: webview The WebView plugin platform-android Android applications specifically c: proposal A detailed proposal for a change to Flutter labels Jan 25, 2021
@cyanglaz cyanglaz added the P3 Issues that are less important to the Flutter project label Mar 25, 2021
@timukasr
Copy link

We'd like to show custom SSL error to users in our app and this feature would be really helpful.
Browsing the code, it seems that adding something like this to WebViewClientHostApiImpl.java could be simple fix:

@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
	if (flutterApi != null) {
		flutterApi.onReceivedError(
			this,
			view,
			(long) WebViewClient.ERROR_FAILED_SSL_HANDSHAKE,
			"Failed to perform SSL handshake",
			error.getUrl(),
			reply -> {}
		);
	}
	handler.cancel();
}

@flutter-triage-bot flutter-triage-bot bot added the package flutter/packages repository. See also p: labels. label Jul 5, 2023
@Hixie Hixie removed the plugin label Jul 6, 2023
@flutter-triage-bot flutter-triage-bot bot added multiteam-retriage-candidate team-android Owned by Android platform team triaged-android Triaged by Android platform team labels Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: proposal A detailed proposal for a change to Flutter p: webview The WebView plugin P3 Issues that are less important to the Flutter project package flutter/packages repository. See also p: labels. platform-android Android applications specifically team-android Owned by Android platform team triaged-android Triaged by Android platform team
Projects
None yet
Development

No branches or pull requests

6 participants