IOS 9 Unable to access HTTP solution _ios

Source: Internet
Author: User
Tags http request

After iOS 9, Apple's default requirement is that the URL to the app must be a secure link to HTTPS, and that the HTTP link is really unsafe, and that is why, if the request fails during the development process, the console displays information about HTTP insecurity using HTTPS. However, since not all developers will apply for HTTPS certificates to support HTTPS access, it is still possible to set up to normally access HTTP, as follows:

1, in the Xcode project to find info.plist files, do the development of iOS should be aware that this is a number of application configuration files;
2, add the dictionary type nsapptransportsecurity field in the Info.plist file;
3, add a Boolean-type nsallowsarbitraryloads field under the Nsapptransportsecurity field and set its value to Yes.

This is OK, the effect is as follows:


At this point, the HTTP network request can be successful, but at the same time will not be able to assess the security of the couple, fundamentally, HTTPS, or as far as possible HTTPS, it will be more secure.

However, in addition to their own request, may be used in the project some of the third Third-party also have network request and also no HTTPS, this time if you do not want to allow HTTP, if you do not support HTTPS, you can use the way to add exceptions.

The way to add exceptions is simple:
Select Open with source code in the Info.plist file
Then add a configuration similar to the following:

 <key>NSAppTransportSecurity</key>
 <dict>
  <key>NSExceptionDomains</key>
  <dict>
   <key>qq.com</key>
   <dict>
    <key>nsincludessubdomains</ key>
    <true/>
   </dict>
   <key>sina.com.cn</key>
   <dict>
    < key>nsincludessubdomains</key>
    <true/>
   </dict>
   </dict>
 </ Dict>

According to the above you look, according to the domain name you need to modify, Nsincludesubdomains, as the name implies is to include subdomains meaning, so you can go to these domain names to open the HTTP request alone, and other applications of their own to maintain the security way https.

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.