问题原因:
安卓系统 7.0 以上版本,微信 7.0 以下版本,微信会信任系统提供的证书
安卓系统 7.0 以上版本,微信 7.0 以上版本,微信只信任它自己配置的证书列表
解决方法:
1.xposed+JustTrustMe
TIP:使用这种方法微信H5无法抓包
2.项目源码中配置文件
(1)在源码res目录下新建xml目录,增加network_security_config.xml文件
工程名/app/src/main/res/xml/network_security_config.xml
<network-security-config> <base-config cleartextTrafficPermitted="true"> <trust-anchors> <certificates src="system" overridePins="true" /> //信任系统证书 <certificates src="user" overridePins="true" /> //信任用户证书 </trust-anchors> </base-config>
(2)修改项目的AndroidManifest.xml文件,在application中增加android:networkSecurityConfig="@xml/network_security_config"
<?xml version="1.0" encoding="utf-8"?> <manifest ... > <application android:networkSecurityConfig="@xml/network_security_config" ... > ... </application>
TIP:需要项目源码,每个项目都要进行配置
3.将证书变为系统证书
(1)安装证书到手机
手机需要Root权限,出现无法安装时候可以软件导出证书到电脑,然后放入手机,通过SD卡进行安装
(2)安装re管理器(Root Explorer)
(3)将/data/misc/user/0/cacerts-added/********.0复制到一个文件夹里,然后从手机系统设置——安全——清除凭证 把charles的证书凭证删除
(4)进入RootExplorer管理器,将********.0证书文件剪贴到/system/etc/security/cacerts/文件夹下,并把文件的权限设置成rw-r-r-
(5)重启手机,进入 设置——安全——信任的凭证——系统标签 里查看证书