Android 7.0 Fixes an issue that does not fetch HTTPS packets

Source: Internet
Author: User
<span id="Label3"></p><span style="color: #000000"><span style="color: #000000"><strong>problem: Android7.0 system, using fiddler cannot crawl HTTPS packets</strong></span></span><span style="color: #000000"><span style="color: #000000"><strong>workaround:</strong></span></span><strong><strong> </strong></strong><p><p><span style="font-size: 14px; color: #000000"><strong>1. Create a new XML directory in the source res directory and add the Network_security_config.xml file</strong></span></p></p><span style="color: #000000"><span style="color: #000000">(project Name/app/src/main/res/xml/network_security_config.xml)</span></span><span style="color: #000000"><span style="color: #000000"> </span></span><span style="color: #000000"><span style="color: #000000">the contents of the Network_security_config.xml file Are:</span></span><pre><span style="color: #0000ff"><span style="color: #0000ff"><</span></span><span style="color: #800000"><span style="color: #800000">Network-security-config</span></span><span style="color: #0000ff"><span style="color: #0000ff">></span></span> <span style="color: #0000ff"><span style="color: #0000ff"><</span></span><span style="color: #800000"><span style="color: #800000">Base-config</span></span><span style="color: #ff0000"><span style="color: #ff0000">cleartexttrafficpermitted</span></span><span style="color: #0000ff"><span style="color: #0000ff">= "true"</span></span><span style="color: #0000ff"><span style="color: #0000ff">></span></span> <span style="color: #0000ff"><span style="color: #0000ff"><</span></span><span style="color: #800000"><span style="color: #800000">trust-anchors</span></span><span style="color: #0000ff"><span style="color: #0000ff">></span></span> <span style="color: #0000ff"><span style="color: #0000ff"><</span></span><span style="color: #800000"><span style="color: #800000">Certificates</span></span><span style="color: #ff0000"><span style="color: #ff0000">src</span></span><span style="color: #0000ff"><span style="color: #0000ff">= "system"</span></span><span style="color: #ff0000"><span style="color: #ff0000">Overridepins</span></span><span style="color: #0000ff"><span style="color: #0000ff">= "true"</span></span> <span style="color: #0000ff"><span style="color: #0000ff">/></span></span> <span style="color: #0000ff"><span style="color: #0000ff"><</span></span><span style="color: #800000"><span style="color: #800000">Certificates</span></span><span style="color: #ff0000"><span style="color: #ff0000">src</span></span><span style="color: #0000ff"><span style="color: #0000ff">= "user"</span></span><span style="color: #ff0000"><span style="color: #ff0000">Overridepins</span></span><span style="color: #0000ff"><span style="color: #0000ff">= "true"</span></span> <span style="color: #0000ff"><span style="color: #0000ff">/></span></span> <span style="color: #0000ff"><span style="color: #0000ff"></</span></span><span style="color: #800000"><span style="color: #800000">trust-anchors</span></span><span style="color: #0000ff"><span style="color: #0000ff">></span></span> <span style="color: #0000ff"><span style="color: #0000ff"></</span></span><span style="color: #800000"><span style="color: #800000">Base-config</span></span><span style="color: #0000ff"><span style="color: #0000ff">></span></span><span style="color: #0000ff"><span style="color: #0000ff"></</span></span><span style="color: #800000"><span style="color: #800000">Network-security-config</span></span><span style="color: #0000ff"><span style="color: #0000ff">></span></span></pre><p><p></p></p><span style="color: #000000"><span style="color: #000000"> </span></span><span style="color: #000000"><span style="color: #000000">description: Certificates Description of Src= "system" represents the CA certificate of the trusted system, src= "user" means trusting the user to import the CA certificate</span></span><span style="color: #000000"><span style="color: #000000"> </span></span><p><p><span style="color: #000000; font-size: 14px"><strong>2. Modify the Project's androidmanifest.xml file, add android:networksecurityconfig= "@xml/network_security_config" in application</strong></span></p></p> <pre><pre><span style="color: #0000ff"><?</span> <span style="color: #ff00ff">XML version= "1.0" encoding= "utf-8"</span> <span style="color: #0000ff">?></span> <span style="color: #0000ff"><</span> <span style="color: #800000"></span> <span style="color: #ff0000"></span> <span style="color: #0000ff">></span> <span style="color: #0000ff"></span><<span style="color: #800000"></span><span style="color: #ff0000">android:networksecurityconfig</span><span style="color: #0000ff">= "@xml/ Network_security_config</span><span style="color: #ff0000"> </span><span style="color: #000000"> " </span> <span style="color: #0000ff">></span>... <span style="color: #0000ff"></</span> <span style="color: #800000">Application</span> <span style="color: #0000ff">></span> <span style="color: #0000ff"></</span> <span style="color: #800000">Manifest</span> <span style="color: #0000ff">></span></pre></pre><p><p></p></p><span style="color: #000000"><span style="color: #000000">description: The value of Android:networksecurityconfig points to the XML file created in the previous step</span></span><span style="color: #000000"><span style="color: #000000"> </span></span><span style="color: #000000"><span style="color: #000000">3. Then pack and install the APK</span></span><span style="color: #000000"><span style="color: #000000">the premise of the phone has to install the Fiddler and other CA certificate ha</span></span><span style="color: #000000"><span style="color: #000000"> </span></span><span style="color: #000000"><span style="color: #000000"><strong>cause of the problem:</strong></span></span><span style="color: #000000"><span style="color: #000000">Android7 system, The user-imported CA certificate is not trusted by default, so a configuration file is required to trust user-imported certificates</span></span><span style="color: #000000"><span style="color: #000000"> </span></span><span style="color: #000000"><span style="color: #000000"> </span></span><span style="font-size: 16px"><span style="font-size: 16px"><strong><span style="color: #000000">Reference Documentation:</span></strong></span></span><span style="color: #000000"><span style="color: #000000"><span style="color: #000000">Https://developer.android.com/training/articles/security-config.html#CustomTrust</span></span></span><span style="color: #000000"><span style="color: #000000"> </span></span> <p><p> Android 7.0 Fixes an issue that does not capture HTTPS packets </p> </p></span>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.