Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to bypass invalid SSL certificate in Flutter InAppWebView

I am using the inappwebview https://pub.dev/packages/flutter_inappwebview plugin for displaying the webview but I am getting an SSL error.

E/chromium(15303): [ERROR:ssl_client_socket_impl.cc(946)] handshake failed; returned -1, SSL error code 1, net_error -200

onReceivedServerTrustAuthRequest: (InAppWebViewController controller, ServerTrustChallenge challenge) async  {
    print('ignoring the ssl');
    return ServerTrustAuthResponse(action: ServerTrustAuthResponseAction.PROCEED);
  },

But it is not working.

Can I get any suggestions for solving the error?

like image 360
raj kavadia Avatar asked Oct 28 '25 04:10

raj kavadia


1 Answers

You can bypass the SSL errors by configuring ServerTrustAuthResponseAction.PROCEED on onReceivedServerTrustAuthRequest similar to the snippet that you've shared.

I've tried the snippet you've shared on flutter_inappwebview: ^5.4.3+7 and it works without issues. It's likely that the error comes from something else. You can also try testing your InAppWebView implementation against "https://self-signed.badssl.com/" - a mock endpoint to test bad SSL configs.

InAppWebView(
  initialUrlRequest: URLRequest(
      url: Uri.parse("https://self-signed.badssl.com/")
  ),
  initialOptions: InAppWebViewWidgetOptions(
      inAppWebViewOptions: InAppWebViewOptions(
        debuggingEnabled: true,
      ),
  ),
  onReceivedServerTrustAuthRequest: (controller, challenge) async {
    return ServerTrustAuthResponse(action: ServerTrustAuthResponseAction.PROCEED);
  },
),
like image 151
Omatt Avatar answered Oct 29 '25 18:10

Omatt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!