OSDN Git Service

Change cleartext traffic permitted default for P apps
authorChad Brubaker <cbrubaker@google.com>
Thu, 19 Oct 2017 20:23:47 +0000 (13:23 -0700)
committerChad Brubaker <cbrubaker@google.com>
Mon, 23 Oct 2017 20:18:59 +0000 (13:18 -0700)
For applications targeting P and above the network security
config's cleartextTrafficPermitted will default to false instead of
the previous true.

Bug: 63931636
Test: network security config cts tests
Change-Id: Ia697358ad84e2092443c3eff518003c6a11e4630

core/java/android/security/net/config/NetworkSecurityConfig.java

index b9e5505..52f48ef 100644 (file)
@@ -164,7 +164,8 @@ public final class NetworkSecurityConfig {
      * <p>
      * The default configuration has the following properties:
      * <ol>
-     * <li>Cleartext traffic is permitted for non-ephemeral apps.</li>
+     * <li>If the application targets API level 27 (Android O MR1) or lower then cleartext traffic
+     * is allowed by default.</li>
      * <li>Cleartext traffic is not permitted for ephemeral apps.</li>
      * <li>HSTS is not enforced.</li>
      * <li>No certificate pinning is used.</li>
@@ -183,7 +184,8 @@ public final class NetworkSecurityConfig {
                 // System certificate store, does not bypass static pins.
                 .addCertificatesEntryRef(
                         new CertificatesEntryRef(SystemCertificateSource.getInstance(), false));
-        final boolean cleartextTrafficPermitted = info.targetSandboxVersion < 2;
+        final boolean cleartextTrafficPermitted = info.targetSdkVersion < Build.VERSION_CODES.P
+                && info.targetSandboxVersion < 2;
         builder.setCleartextTrafficPermitted(cleartextTrafficPermitted);
         // Applications targeting N and above must opt in into trusting the user added certificate
         // store.