android使用Charles抓包https请求

xiaoxiao2021-02-27  133

最近编辑于2018年6月29日

按照正常抓http的方式进行抓包,会出现如下情况:

 

https抓包就是需要在电脑端和移动端装上安全证书。

电脑端的安装:

手机端就是需要到手机浏览器打开chls.pro/ssl下载安全证书安装到手机上,如下所示:

再在青花瓷上设置一下SSL Proxying,7.0以下的android手机就能正常抓包了:

 

 

但是在7.0的手机上还会出现以下情况:

这是android7.0安全策略问题。手机持有者也没有权限,只有该应用自己设置安全证书,你才能抓到该应用的https数据。

添加安全配置文件

 

<?xml version="1.0" encoding="utf-8"?> <manifest ... >     <application android:networkSecurityConfig="@xml/network_security_config"                     ... >         ...     </application> </manifest>xml version="1.0" encoding="utf-8"?> <manifest ... >     <application android:networkSecurityConfig="@xml/network_security_config"                     ... >         ...     </application> </manifest>

配置用于调试的 CA

在res文件夹下新建xml文件夹,再在xml文件夹下新建network_security_config.xml文件:

 

<?xml version="1.0" encoding="utf-8"?> <network-security-config>     <debug-overrides>         <trust-anchors>             <certificates src="@raw/debug_cas"/>         </trust-anchors>     </debug-overrides> </network-security-config>xml version="1.0" encoding="utf-8"?> <network-security-config>     <debug-overrides>         <trust-anchors>             <certificates src="@raw/debug_cas"/>         </trust-anchors>     </debug-overrides> </network-security-config>

然后在res文件夹下新建raw文件夹,将手机上下载的安全证书重命名为"debug_cas"(没有后缀),并放到raw文件夹下。安全证书可到如下地址下载:http://www.charlesproxy.com/getssl/

 

最终就能正常抓包了。

 

参考链接

http://blog.csdn.net/u011045726/article/details/76064048

https://developer.android.google.cn/training/articles/security-config.html#CustomTrust

转载请注明原文地址: https://www.6miu.com/read-15617.html

最新回复(0)