Home > other >  How to set cleartextTrafficPermitted to true only in debug mode?
How to set cleartextTrafficPermitted to true only in debug mode?

Time:10-11

Currently I have the following network security config xml file:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
  <!-- default config that does not allow clear test -->
    <base-config cleartextTrafficPermitted="false">
        <trust-anchors>
            <certificates src="system" />
        </trust-anchors>
    </base-config>
    
  <!-- trying to get debug override to change this -->
    <debug-overrides cleartextTrafficPermitted="true (DOESN'T WORK)">
        <trust-anchors>
            <certificates src="system" />
            <certificates src="user" />
        </trust-anchors>
    </debug-overrides>
</network-security-config>

All I am trying to do is conditionally enabled global domain clear traffic during development/debug mode.

I thought I had my answer when I discovered the tag <debug-overrides>...</debug-overrides>.

enter image description here

CodePudding user response:

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

Use domain config is the better way.We don't usually use http in a formal environment.

  • Related