最近很多同事反馈使用Charles抓包出现了很多unknown的问题,现象如下图
查看右侧的原因,给出的结果是这样的
这里将讲解如何解决这个问题,但是开始阅读之前,请确认符合如下的条件
好的,开始了。
在应用xml目录下新建一个名为network_security_config.xml
,内容为
1 2 3 4 5 6 7 8 | <network-security-config> <debug-overrides> <trust-anchors> <!-- Trust user added CAs while debuggable only --> <certificates src="user" /> </trust-anchors> </debug-overrides> </network-security-config> |
---|
上面的代码仅仅在debug编译包,信任用户添加的CA证书
在AndroidManifest Application节点增加属性
1 2 3 4 5 6 7 | <?xml version="1.0" encoding="utf-8"?> <manifest ... > <application android:networkSecurityConfig="@xml/network_security_config" ... > ... </application> </manifest> |
---|
建议重启应用,就能解决问题了。
考虑到安全问题,上面的实现
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有