美文网首页
android 7.0后手机手包问题

android 7.0后手机手包问题

作者: fyg | 来源:发表于2020-07-22 19:04 被阅读0次
    7.0适配1.png

    上图中用到的内容会放到我的github中。

    为什么要这样的配置?

    之前测试反馈,用我手机莲我charles可以抓包,但用手机莲他charles不行,导致该问题的原因,有可能是
    每人安装Charles时Charles生成的公私钥是不同的,这样一来,如果想要手机都能够连接他们的Charles,那么手机上就得都安装一下他们各自Charles导出的证书,这样的操作会非常的繁琐,因为测试和开发经常互换手机手包,为了避免这样的问题,我统一生成了一个公私钥,这样大家电脑上 Charles的根证书是一致的,手机上也是一致的,就很好的解决了这个问题。

    两证书的区别

    注电脑Charles安装的是 sharles.p12 证书
    手机安装的是sharles.cer证书
    这两个 证书是有区别的, sharles.p12 中有公钥和私钥,而 sharles.cer证书是只有 公钥 ,这就是它可以做为中间代理人的原因

    默认release 生产包是不允许抓包

    如果要抓请打debug包或清单文件中在application标签下手动加上android:debuggable="true"

    之前代码如下配置

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

    改为如下后可以

    <?xml version="1.0" encoding="utf-8"?>
    <network-security-config>
        <base-config cleartextTrafficPermitted="true" />
        <debug-overrides>
            <trust-anchors>
                <certificates src="user" />
            </trust-anchors>
        </debug-overrides>
    </network-security-config>
    

    手机安装证书时凭据用途如何选

    记得手机安装证书时,凭据用途会有两种模式选择(VPN和应用 wifi ),至于这两个的区别,暂时未知,但不影响使用,如果你手机安装 证书时选择了 【VPN和应用】后,不能抓包的话,请尝试使用 【wifi 模式】在安装一次。


    凭据用途.png

    参考:
    网络安全配置

    manage the root certificate used by charles to establish ssl connections to clients
    
    
    
    Charles uses its own Root SSL certificate for SSL requests through Charles to hosts enabled for SSL Proxying. The Root certificate is generated automatically for each Charles installation.
    Because Charles has signed the Root certificate itself, it won't be trusted by your browsers or applications. In order to use the SSL Proxying feature in Charles you therefore need to add the Root certificate for your copy of Charles to the trust-store on your OS, and perhaps in your browser.
    Use the options in the SSL submenu in the Help menu in Charles to help install the Root certificate. You can install the certificate on the current OS, or on remote devices or browsers.
    To install the certificate in Mozilla Firefox, first install the Mozilla Firefox Add-on for Charles, from the Help menu in Charles, and then use the option to install the Root certificate from the Charles menu in the Tools menu in Firefox.
    
    
    

    相关文章

      网友评论

          本文标题:android 7.0后手机手包问题

          本文链接:https://www.haomeiwen.com/subject/jpszkktx.html