Android WebView SSL #39;Security Warning#39;(Android WebView SSL“安全警告)
问题描述
我正在为客户构建应用的测试版本.此应用程序的一部分使用调用基于 SSL 的站点的 WebView.反过来,客户端提供了一个测试域,其中证书名称与 FQDN 不匹配.唉,他们无法提供匹配的证书.:(
I'm building a test version of an app for a client. Part of this app uses a WebView that calls out to a SSL-based site. In turn, the client has provided a test domain where the certificate name does not match the FQDN. Alas, they are not in a position to provision a cert that matches. :(
我正在使用一行代码在配套的 iOS ad hoc 应用程序上解决此问题(同样,不用于生产用途 - 仅用于测试目的).我已经在 Android 操作系统上搜索过类似的信息,但相比之下,我在这里和其他地方看到的解决方案足以让我头晕目眩!
I'm working around this issue on the companion iOS ad hoc app with one line of code (again, not for production use - just for test purposes). I have searched for similar info on Android OS, but the solutions I've seen here and elsewhere are enough to make my head spin big time by comparison!
有没有一种简单的方法来解决这个问题?甚至隐藏在某个地方的面向用户的设置?
Is there a straightforward way to work around this? Even a user-facing setting tucked away somewhere?
感谢线索!
推荐答案
创建一个 WebViewClient 并处理如下所示的 onReceivedSslError:
Create a WebViewClient and handle the onReceivedSslError which looks like this:
public void onReceivedSslError (WebView view, SslErrorHandler handler, SslError error)
在此回调中,您只需调用 handler.proceed()
即可继续加载页面.如果您不处理此回调并调用 proceed()
方法,则默认行为将是页面不加载.
Inside this callback you can just call handler.proceed()
and the page will continue loading. If you don't handle this callback and call the proceed()
method then the default behaviour will be for the page not to load.
这篇关于Android WebView SSL“安全警告"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Android WebView SSL“安全警告"


- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01