zoukankan      html  css  js  c++  java
  • Android 7.0 fiddler代理抓不到https请求的解决办法

    解决方法: 

    1.在源码res目录下新建xml目录,增加network_security_config.xml文件

    (工程名/app/src/main/res/xml/network_security_config.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>

    </network-security-config>

    说明:certificates说明的src="system"表示信任系统的CA证书,src="user"表示信任用户导入的CA证书
     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>
    </manifest>

    说明:android:networkSecurityConfig的值指向的就是上一步创建的xml文件
     
    3.然后再打包安装apk即可
    前提手机已经要安装了fiddler等CA证书
     

    问题原因:

    Android7系统,默认不信任用户导入的CA证书,所以需要配置文件,来信任用户导入的证书
     
    参考:
    https://developer.android.com/training/articles/security-config.html#CustomTrust
     
     
  • 相关阅读:
    E. You Are Given Some Strings...
    神奇函数
    AC自动机再加强版
    AC自动机2
    AC自动机
    three arrays
    permutation 2
    string matching
    permutation 1
    equation
  • 原文地址:https://www.cnblogs.com/yaks/p/6946246.html
Copyright © 2011-2022 走看看