Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App Transport Security policy requires the use of a secure connection - IOS 9

Tags:

ios

connection

I'm facing problem connection to API with using IP address. Even I had add the following code to plist, it still show error as below:

"http://xx3.xx.xx8.xx7/xxx/xxx/ error: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection."

This is the code I add to the plist

     <key>xx3.xx.xx8.xx7</key>
        <dict>
            <key>NSThirdPartyExceptionMinimumTLSVersion</key>
            <string>TLSv1.1</string>
            <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
            <false/>
            <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
    </key>
like image 311
user831098 Avatar asked Sep 22 '15 08:09

user831098


People also ask

What is App transport security iOS?

App Transport Security (ATS) is a privacy feature introduced in iOS 9. It's enabled by default for new apps and enforces secure connections.

What is App transport security exception?

Domain Exceptions Keys App Transport Security imposes a number of rules on an application's network behavior. These rules not only relate to the use of the HTTPS protocol for making network requests, though. They also apply to the configuration of the server your application communicates with.


2 Answers

Document Allowing Insecure Connection to a Single Server here. So you must add NSAppTransportSecurity to your info.plist file in truth way like flowing (to show Info.plist in source, in Xcode right click to Info.plist "Open As"->"Source Code")

To configure a per-domain exception:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <!--others key-->
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>insecure-domain1.example.com</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <true/>
                <key>NSExceptionRequiresForwardSecrecy</key>
                <false/>
                <key>NSExceptionMinimumTLSVersion</key>
                <string>TLSv1.0</string>
            </dict>
            <key>insecure-domain2.example.com</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <true/>
                <key>NSExceptionRequiresForwardSecrecy</key>
                <false/>
                <key>NSExceptionMinimumTLSVersion</key>
                <string>TLSv1.0</string>
            </dict>
        </dict>
    </dict>
    <!--others key-->
</dict>
</plist>

after edit Infor.plist file look like following: enter image description here

Or disable ATS:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    ...
    <key>NSAppTransportSecurity</key>
    <dict>
        <!--Include to allow all connections (DANGER)-->
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
</dict>
</plist>

after edit Infor.plist file look like following: enter image description here

like image 132
larva Avatar answered Apr 29 '23 12:04

larva


Simple & Easiest Solution just in 3 Steps

enter image description here

Add the following two properties & run again... happy coding :-)

enter image description here

like image 40
iAj Avatar answered Apr 29 '23 13:04

iAj