我正在使用 Crosswalk XWalkView 作为我的应用程序的 WebView ,现在我正在加载一些具有有效证书并且在 Android 版本 < 7 中运行良好的网站。
但在 Android 7.0 及更高版本中,我收到了这条 toast 消息REQUEST WAS DENIED FOR SECURITY
和这个日志
06-12 17:46:46.024 22518-22731/? I/X509Util: Failed to validate the certificate chain, error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
我读过一些类似的问题,但发布的解决方案是在 Cordova 中(参见 this)。我正在使用 native android,我想知道如何在我这边( native )执行此操作。
引用自链接
I solved this by adding the last 3 lines of the following snippet to config.xml:
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
<allow-navigation href="data:*" />
谢谢!
基本上我想做的是像 Cordova 那样拥有一些白名单,但我不知道如何使用原生 Android 和 Crosswalk 实现这一点。首先,我不知道原生 android 中是否有 config.xml(在 cordova 中有),现在我真的需要知道如何在我的项目中实现它。
最佳答案
我按照 android network security config 中的步骤解决了这个问题我信任额外的证书。
基本上,我第一次尝试时在我的 network_security_config 中提供了错误的 SSL 证书(我假设它是网站本身,但导致错误的是网站中加载的 Javascript 文件的主机) .xml.
website_ca is the SSL certificate file
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config>
<trust-anchors>
<certificates src="@raw/website_ca"/>
<certificates src="system"/>
</trust-anchors>
</base-config>
</network-security-config>
现在一切正常
关于android - 人行横道 XWalkView : Request was denied for Security (Android 7. 0 及更高),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44714940/