Bie*_*iel 3 ssl-certificate webview android-webview flutter
我们目前有一个为在线订购实用程序创建的 Angular Web 应用程序。但我们想用它创建一个本机应用程序,并且我们想使用 Flutter。
首先,我们只是想使用 Web 视图来显示现有的 Angular 应用程序。
问题是,我们想要这样做是因为我们还想摆脱通过手机访问应用程序时对 SSL 证书的需要。
webview还需要SSL证书吗?
我想这是因为它仍然像访问网页一样,但我想确定一下。
该webview_flutter插件没有任何选项来忽略 SSL 错误。\n相反,使用我的flutter_inappwebview插件,可以非常简单地忽略 SSL 错误,就像您通常在 Android 上所做的那样,即使用onReceivedServerTrustAuthRequest\xc2\xa0event 并返回ServerTrustAuthResponse(action: ServerTrustAuthResponseAction.PROCEED);指定的值请求或所有请求。
使用最新版本5.0.5+3和https://badssl.com/(这是一个用于针对不良 SSL 配置测试客户端的网站,请参阅https://github.com/chromium/badssl.com)的一个简单示例是:
child: InAppWebView(\n initialUrlRequest: URLRequest(\n url: Uri.parse("https://self-signed.badssl.com/")\n ),\n onReceivedServerTrustAuthRequest: (controller, challenge) async {\n print(challenge);\n return ServerTrustAuthResponse(action: ServerTrustAuthResponseAction.PROCEED);\n },\n),\nRun Code Online (Sandbox Code Playgroud)\n其中challenge\xc2\xa0 参数提供有关挑战的所有信息,例如主机、协议、领域等。
另外,在 Android 上,当您返回要执行的操作 ( PROCEED\xc2\xa0or CANCEL) 时,此决定由 Android 本身保存,因此下次您访问同一 URL 时,onReceivedServerTrustAuthRequest将不会触发 \xc2\xa0 事件.\n在这种情况下,您可以使用该controller.android.clearSslPreferences()方法清除 Android SSL 首选项。
| 归档时间: |
|
| 查看次数: |
13236 次 |
| 最近记录: |