针对那种能抓到http请求的包单抓不到https的包且app运行正常
原理:
系统证书的目录是:/system/etc/security/cacerts/
每个证书的命名规则为:<Certificate_Hash>.
Certificate_Hash 表示证书文件的 hash 值,Number 是为了防止证书文件的 hash 值一致而增加的后缀;
证书的 hash 值可以由命令计算出来,在终端输入 openssl x509 -subject_hash_old -in <Certificate_File>,其中 Certificate_File 为证书路径,将证书重命名为 hash.0 放入系统证书目录,之后你就可以正常抓包了。
首先将抓包软件的证书导出(以fiddler为例)
计算Certificate_Hash的值
电脑上首先安装openssl
http://slproweb.com/products/Win32OpenSSL.html
下载安装配置环境变量就行了
执行命令
MAC或linux执行:openssl x509 -subject_hash_old -in .\FiddlerRoot.cer
windows执行:openssl x509 -subject_hash_old -in .\FiddlerRoot.cer -inform der
windows执行openssl x509 -subject_hash_old -in <Certificate_File>会报unable to load certificate的错误
269953fd就是证书hash的值了
将证书改名
将证书重命名为 hash.0 放入手机的/system/etc/security/cacerts/下
不要直接用adb push,安卓5以后有问题,不通用。
先把文件放入手机内
这样文件会存储在 /storage/emulated/0
然后把文件移动到/system/etc/security/cacerts/下,手机需要完全root,这很重要
提供一个我做好的fiddler的证书
链接:https://pan.baidu.com/s/12txjRlCQb4WiIDX_2js1bA
提取码:bmi5