Home > front end >  Multiple subdomains in network_security_config.xml how
Multiple subdomains in network_security_config.xml how

Time:03-28

Hi is it possible to have multiple subdomains in the network_security_config?

See example below: I could not find anyexamples with multiple ones.

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
  <domain-config cleartextTrafficPermitted="false">
      <domain includeSubdomains="true">whatever.com</domain>
      <domain includeSubdomains="true">anotherone.com</domain>
    <pin-set>
        <pin digest="SHA-256">whatever.compinhere</pin>
        <pin digest="SHA-256">anotherone.compinhere/TLRbotnEw=</pin>
        <!-- backup pin -->
        <pin digest="SHA-256">backuppinwhatever.compinhere</pin>
       <pin digest="SHA-256">backuppinanotherone.compinhere/TLRbotnEw=</pin>
    </pin-set>
  </domain-config>
</network-security-config>

or is this below correct

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
  <domain-config cleartextTrafficPermitted="false">
      <domain includeSubdomains="true">whatever.com</domain>
    <pin-set>
        <pin digest="SHA-256">whatever.com in here</pin>
        <!-- backup pin -->
    </pin-set>
  </domain-config>
  <domain-config cleartextTrafficPermitted="false">
        <domain includeSubdomains="true">anotherone.com</domain>
        <pin-set>
            <pin digest="SHA-256">anotherone.cominhere</pin>
            <!-- backup pin -->
        </pin-set>
  </domain-config>
</network-security-config>

Which one of the above is valid way of doing it? Many thanks

CodePudding user response:

According to the official document, the network_security_config can contain any number of <domain-config> and the <domain-config> can contain 0 or 1 <pin-set> which can contain any number of <pin>.

So it seems that the two examples you provided are both right.

If you need more information, please check the official document: https://developer.android.com/training/articles/security-config

  • Related