Friday, January 13, 2017

App Transport Security Exception using Info.plist

Here's a short snippet to allow domain exceptions in Info.plist. Method 1 is not recommended, because it will allow all domains. Method 2 is recommended.

Method 1: Not recommended (all domains are accessible) <plist> <dict> . . . <key>NSAppTransportSecurity</key> <dict> <!-- Allows all connections regardless --> <key>NSAllowsArbitraryLoads</key> <true /> </dict> . . . </dict> </plist>
Medhod 2: Recommended (only mysite.com is allowed) <plist> <dict> . . . <key>NSAppTransportSecurity</key> <dict> <key>NSExceptionDomains</key> <dict> <key>mysite.com</key> <dict> <key>NSExceptionAllowsInsecureHTTPLoads</key> <true /> <key>NSIncludesSubdomains</key> <true /> </dict> </dict> </dict> . . . </dict> </plist>

No comments: