MrWos
MrWos
  • 发布:2024-07-31 17:15
  • 更新:2024-07-31 17:15
  • 阅读:127

漏扫中“未配置网络安全属性风险”如何正确姿势进行配置

分类:uni-app

一个产品中漏扫出现了“未配置网络安全属性风险”。
初期查到官网有解决方案:https://uniapp.dcloud.net.cn/tutorial/app-sec-android.html
实践了一下,发现还是需要很多细节需要纠结。测试了几遍漏扫。留下以下资料供大家参考
新加目录结构和文件

/nativeResources  
--android  
----res  
------raw  
--------my_ca (文件是https证书的nginx的.key文件内容)  
------xml  
--------network_security_config.xml  
/AndroidManifest.xml  
/manifest.json (需要修改)

network_security_config.xml

<?xml version="1.0" encoding="utf-8"?>  
<network-security-config>  
    <domain-config cleartextTrafficPermitted="false">  
        <domain includeSubdomains="true">你接口的域名</domain>  
        <trust-anchors>  
            <certificates src="@/raw/my_ca"/>  
        </trust-anchors>  
    </domain-config>  
</network-security-config>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>  
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"   
  package="包名">  
    <application android:networkSecurityConfig="@xml/network_security_config"></application>  
</manifest>

manifest.json

...  
"distribute" : {  
            /* android打包配置 */  
            "android" : {  
                "networkSecurityConfig" : "xml/network_security_config.xml", //新加入的行  

...
0 关注 分享

要回复文章请先登录注册