raj*_*dia 4 ssl android flutter flutter-layout
我正在使用 inappwebview https://pub.dev/packages/flutter_inappwebview插件来显示 webview,但出现 SSL 错误。
E/chromium(15303): [错误:ssl_client_socket_impl.cc(946)] 握手失败;返回 -1,SSL 错误代码 1,net_error -200
onReceivedServerTrustAuthRequest: (InAppWebViewController controller, ServerTrustChallenge challenge) async {
print('ignoring the ssl');
return ServerTrustAuthResponse(action: ServerTrustAuthResponseAction.PROCEED);
},
Run Code Online (Sandbox Code Playgroud)
但它不起作用。
我可以获得解决该错误的任何建议吗?
ServerTrustAuthResponseAction.PROCEED您可以通过onReceivedServerTrustAuthRequest类似于您共享的代码片段的配置来绕过 SSL 错误。
我已经尝试过您在 flutter_inappwebview 上分享的代码片段:^5.4.3+7,它可以正常工作。该错误很可能来自其他原因。您还可以尝试针对“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);
},
),
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4781 次 |
| 最近记录: |