How can I add NSAppTransportSecurity to my info.plist file?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
In iOS development, the `NSAppTransportSecurity` key in the `info.plist` file plays a crucial role in defining the network security configurations of your app. Apple's App Transport Security (ATS) feature ensures that apps adhere to best practices for secure internet connections by enforcing HTTPS and restricting weaker cryptographic techniques.
Understanding NSAppTransportSecurity
The `NSAppTransportSecurity` dictionary in your `info.plist` file provides a way to specify exceptions for your app regarding HTTP connections. This feature aims to promote security by default, requiring apps to use secure connections (HTTPS) rather than insecure ones (HTTP), unless explicitly configured otherwise.
Key Configurations
Below are important configurations you can include in the `NSAppTransportSecurity` dictionary:
- `NSAllowsArbitraryLoads`: Allows all loads regardless of the security protocol. It's generally discouraged to set this key to `true` because it disables ATS for all domains, undermining network security. Use this only if absolutely necessary and ideally alongside specific exceptions.
- `NSAllowsArbitraryLoadsForMedia`: Permits insecure connections for loading media files. This can be useful if your app needs to load resources like podcasts, audio, or video over non-secure connections.
- `NSAllowsArbitraryLoadsInWebContent`: Allows non-secure loads in web views. It applies primarily when using web views in your app, accommodating potentially legacy or external content that doesn’t comply with ATS requirements.
- `NSTemporaryExceptionAllowsInsecureHTTPLoads`: Temporary exception for specific domains to allow HTTP loads. It’s suitable for backward compatibility but should be minimized or planned for removal in the future.
- `NSExceptionDomains`: A dictionary containing domain-specific exceptions allowing fine-grained control over network security rules.
Example Configuration
Below is an example of a typical `NSAppTransportSecurity` configuration within `info.plist`:
- Avoid Disabling ATS Globally: Setting `NSAllowsArbitraryLoads` to `true` for all requests is not advisable unless no other solution exists.
- Domain-Specific Exceptions: Use `NSExceptionDomains` to specify precise domains that require exceptions, allowing you to maintain global security standards while catering to specific needs.
- Plan for Future Compatibility: Consider updating or removing exceptions over time to ensure your app complies with evolving security standards.
Related reading
- How can I allow a Group to assume a Role?
- How can I close some specific port on Linux?
- How can I control user access to Amazon DynamoDB data via IAM?
- How can I create a keystore?
- How can I add the new Floating Action Button between two widgets/layouts
- How can I assign an ID to a view programmatically?
- How can I create a product key for my C application?
- How can I create a self-signed certificate using C?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.