Configuration of network_security_config

Hi,

I follow this guide to configurate "network_security_config" https://developer.android.com/training/articles/security-config?hl=es-419 and don't work for me. The app response all the domains and certifcates, not only the configurated in "network_security_config"

In the AndroidManifest.xml, i added <application android:networkSecurityConfig="@xml/network_security_config" />

And there is my network_security_config

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
  <domain-config>
    <domain includeSubdomains="true">mysite.com</domain>
    <trust-anchors>
      <certificates src="@raw/comodo"/>
    </trust-anchors>
  </domain-config>
</network-security-config>

What could be the problem?

Answers

  • JarvanJarvan Member, Xamarin Team Xamurai

    Try to set cleartextTrafficPermitted to 'false' to protect sensitive traffic from hostile networks.

    <network-security-config>
      <domain-config cleartextTrafficPermitted="false">
        <domain includeSubdomains="true">example.com</domain>
      </domain-config>
    </network-security-config>
    
  • eliseogambaeliseogamba Member ✭✭

    Hi

    I tried and keep responding to all urls

  • eliseogambaeliseogamba Member ✭✭

    Hi,

    I tried with what the link says, and not working for me

    Responde all urls.

    Manifest:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.mobile" android:installLocation="auto" android:versionName="1.0.0" android:versionCode="1">
        <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
        <application android:label="Example" android:icon="@mipmap/ic_launcher" android:theme="@style/Theme" android:networkSecurityConfig="@xml/network_security_config">
            <uses-library android:name="org.apache.http.legacy" android:required="false" />
        </application>
    </manifest>
    

    Network_security_config:

    <?xml version="1.0" encoding="utf-8"?>
    <network-security-config>
      <domain-config cleartextTrafficPermitted="false">
        <domain includeSubdomains="true">mobile.example.com</domain>
      </domain-config>
    </network-security-config>
    
  • eliseogambaeliseogamba Member ✭✭

    Help!!!!

Sign In or Register to comment.