How do I load an HTTP URL with App Transport Security enabled in iOS 9?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
In iOS 9, Apple introduced a new security feature called App Transport Security (ATS), which aims to enhance data protection by enforcing secure connections between an app and web services. By default, ATS requires all HTTP connections to be upgraded to HTTPS, which means that any attempts to load non-secure HTTP URLs would result in failure.
However, there are scenarios where an app may need to access an HTTP URL. To allow HTTP communication when ATS is enabled, you have to configure your app’s Info.plist file to include exceptions to the default security policies. Below is a detailed guide explaining how to configure ATS to load HTTP URLs in iOS 9.
How App Transport Security Works
- Secure Defaults: ATS requires the use of HTTPS connections only.
- TLS Version: The server must support at least Transport Layer Security (TLS) 1.2.
- Strong Ciphers: Secure ciphers are necessary to establish a secured connection.
- Certificate Transparency: Ensures that the server’s certificate is correctly registered.
Configuring App Transport Security
Step 1: Identify the Need
Before proceeding with disabling ATS for specific domains, it's crucial to assess whether it’s absolutely necessary. Using HTTPS is strongly recommended to ensure data security and privacy.
Step 2: Modify the Info.plist File
You can disable ATS or configure exceptions to allow HTTP requests by making specific changes to your app’s Info.plist file. Here's a step-by-step process:
- Open your Xcode project.
- Navigate to the 'Info.plist' file.
Step 3: Add ATS Exceptions
To configure ATS exceptions, add the following XML snippet to your Info.plist:
Explanation of Keys
- NSAllowsArbitraryLoads: Allows all HTTP requests globally within the app (not advised unless necessary).
- NSExceptionDomains: Specifies which domains can bypass ATS restrictions.
- NSIncludesSubdomains: Applies the configuration to all the subdomains of the specified domain.
- NSTemporaryExceptionAllowsInsecureHTTPLoads: Allows HTTP requests temporarily for specific domains.
- NSTemporaryExceptionMinimumTLSVersion: Specifies the minimum TLS version required.
Summary Table
| ATS Configuration Key | Description |
NSAllowsArbitraryLoads | Allows all network loads irrespective of transport security settings. |
NSExceptionDomains | A dictionary of domains for which ATS exceptions are allowed. |
NSIncludesSubdomains | Boolean value to include subdomains in ATS exceptions. |
NSTemporaryExceptionAllowsInsecureHTTPLoads | Allows insecure HTTP loads for specified domains. |
NSTemporaryExceptionMinimumTLSVersion | Defines the minimum TLS version for exceptions. |
Additional Considerations
- Security Best Practices: Always aim to use HTTPS endpoints to protect user data.
- Evaluate Legacy Systems: If connecting to legacy systems, consider upgrading them to support HTTPS.
- Compliance: Ensure that your app complies with Apple's security policies and passes the App Store review.
Conclusion
While it is possible to load HTTP URLs in iOS 9 by configuring exceptions in the Info.plist file, it is imperative from a security standpoint to prioritize secure, HTTPS connections. If exceptions must be made, implement them carefully and restrict them to specific cases or domains only. Following these guidelines will help maintain the integrity and security of your app while accommodating necessary exceptions to ATS settings.
Related reading
- How do I make a large number of concurrent HTTPS requests robustly in Clojure /Java
- How do I make calls to a REST API using C?
- How do I mock a REST template exchange?
- How do I modify proxy responses using asynchronous servlets?
- How do I prevent malicious DHT clients that might want to alter/delete my DHT data?
- How do I protect Python code from being read by users?
- How do I locate the CGRect for a substring of text in a UILabel?
- How do I make a custom initializer for a UIViewController subclass in Swift?

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.