Android WebView SSL“安全警告"

Android WebView SSL #39;Security Warning#39;(Android WebView SSL“安全警告)
本文介绍了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“安全警告"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)