[英]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.我正在使用 inappwebview https://pub.dev/packages/flutter_inappwebview插件来显示 webview 但我收到 ZEA52C36203C5F99C3CE2442D531B12 错误。
E/chromium(15303): [ERROR:ssl_client_socket_impl.cc(946)] handshake failed; E/chromium(15303): [ERROR:ssl_client_socket_impl.cc(946)] 握手失败; returned -1, SSL error code 1, net_error -200
返回 -1,SSL 错误代码 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?我可以得到解决错误的任何建议吗?
You can bypass the SSL errors by configuring ServerTrustAuthResponseAction.PROCEED
on onReceivedServerTrustAuthRequest
similar to the snippet that you've shared.您可以通过在
onReceivedServerTrustAuthRequest
上配置类似于您共享的代码段的ServerTrustAuthResponseAction.PROCEED
来绕过 SSL 错误。
I've tried the snippet you've shared on flutter_inappwebview: ^5.4.3+7 and it works without issues.我已经尝试过您在flutter_inappwebview 上分享的片段:^5.4.3+7 ,它可以正常工作。 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.
您还可以尝试针对“https://self-signed.badssl.com/”测试您的 InAppWebView 实现 - 一个用于测试错误 SSL 配置的模拟端点。
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);
},
),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.