Android7.0 和 Charles 的抓包 出现无法抓包unknown和证书无效

Android7.0 和 Charles 的抓包
关于android手机在mac版charles上抓不到包这个问题困扰了很久,查阅了很多资料,发现是android7.0系统安全策略问题。

Charles抓包正常流程
1.在手机上配置证书

点击后:直接在手机浏览器输入: chls.pro/ssl
ps:最好用UC浏览器 华为自带浏览器会下载一个pem文件,会直接在手机上无法安装

2.在电脑上保存加密文件
这里写图片描述

ps:这个证书后面会用到

3.设置访问域名和端口
这里写图片描述

这里写图片描述

ps:大部分人会设置Host:* port:443 ;但是如果直接点击OK也是没有问题的

以上的步骤在随便一搜都可以找到的,但是,上面是针对ios和一部分android机子可行,android7.0的机子再去用charles抓包时候会出现一下情况:
各种unknown

这里写图片描述

此时此刻,把目光转移到代码上来,不管你在charles怎么配置都是无济于事的

Android
As of Android N, you need to add configuration to your app in order to have it trust the SSL certificates generated by Charles SSL Proxying. This means that you can only use SSL Proxying with apps that you control.

In order to configure your app to trust Charles, you need to add a Network Security Configuration File to your app. This file can override the system default, enabling your app to trust user installed CA certificates (e.g. the Charles Root Certificate). You can specify that this only applies in debug builds of your application, so that production builds use the default trust profile.

Add a file res/xml/network_security_config.xml to your app:









Then add a reference to this file in your app’s manifest, as follows:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值