Fix iOS 9 App Transport Security Issues In Apache Cordova

The release of iOS 9 has caused a mess of problems in the Apache Cordova, Ionic Framework, and PhoneGap communities.  Problems spanning from styling issues, to permission issues, and even stricter security requirements that Apache Cordova wasn’t ready to handle.

Here I’m going to discuss App Transport Security (ATS) an issue that is rapidly appearing amongst app developers.

If your Apache Cordova application uses the InAppBrowser plugin to access external resources such as websites, you might have experienced the following error:

SSL Error

Shell

1

webView:didFailLoadWithError - -1200: An SSL error has occurred and a secure connection to the server cannot be made.

Although not fun to see, it is actually a good thing because iOS wants connections to be secure.  This security measure can actually be overwritten to allow your application to perform like it did in earlier versions of iOS.  You need to add the following to your Xcode info.plist file:

info.plist

XHTML

1

2

3

4

5

<key>NSAppTransportSecurity</key>  

<dict>  

    <key>NSAllowsArbitraryLoads</key>

    <true />  

</dict>

Building and running your application again should present better results.  ATS is not limited to only the InAppBrowser plugin, even though that is the most reported cause that I see.

A Real Life Example

Let’s say you are using the ng-cordova-oauth library that I wrote.  Out of the box it will work fine with Android and iOS versions earlier than 9.0.  However in iOS 9 you’ll get ATS errors.  When you try to initiate the oauth login flow you’ll be left with a blank screen wondering what went wrong.

If you don’t want to disable App Transport Security for all domains, you can make domain exceptions as described in the official documentation released by Apple.  This will keep application security as strong as possible.

Conclusion

As much of a pain App Transport Security (ATS) seems in iOS 9, it is actually a positive thing for your users.  With a few modifications you can make exceptions to allow communication between the application and insecure external resources.

时间: 2024-09-19 04:12:50

Fix iOS 9 App Transport Security Issues In Apache Cordova的相关文章

App Transport Security(ATS)

iOS 9 ,跑了下我们的应用,发现有些网络请求失效了.先前在WWDC 2015上了解到iOS 9将要求网络请求使用HTTPS协议,但一直没有在iOS 9 beta版上跑过.现在这个问题突显出来了,所以搜了一些博文研究了一下. 我们知道,Apple在安全及用户隐私方面做了很多工作,包括沙盒机制.代码签名.禁用私有API等.而在今年6月份的WWDC 2015上,Apple又提出了App Transport Security(ATS)的概念.这一特性的主要意图是为我们的App与服务器之间提供一种安全

Rest Assured - Ways to Avoid Security Issues When Using RESTful

With Representational Stateful Transfer technology (commonly known as RESTful architectures) rise to prominence, developers have witnessed the emergence of some seemingly undetectable security issues. These problems, however, are absolutely avoidable

Xcode 7中http通信出现如下错误:Application Transport Security has blocked a cleartext HTTP (http://)

进来买了苹果的证书,发现各种问题. xcode6 无法在我的iphone6s上进行测试.只好升级到7 Xcode 7中http通信出现如下错误:Application Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file. 字

iOS 的 APP 在系统中如何适应 iPhone 5s/6/6 Plus 三种屏幕的尺寸?

初代iPhone 2007年,初代iPhone发布,屏幕的宽高是 320 x 480 像素.下文也是按照宽度,高度的顺序排列.这个分辨率一直到iPhone 3GS也保持不变. 那时编写iOS的App(应用程序),只支持绝对定位.比如一个按钮(x, y, width, height) = (20, 30, 40, 50),就表示它的宽度是40像素,高度是50像素,放在(20, 30)像素的位置. iPhone 4 2010年,iPhone 4发布,率先采用Retina显示屏,在屏幕的物理尺寸不变的

开发一个ios的app采用的技术架构是什么呀

问题描述 开发一个ios的app采用的技术架构是什么呀 是传统的分布式系统么?阿里云提出的云端开发一个app属于哪种方式呢,与传统的开发有什么不同. 解决方案 开发一个ios程序一般使用C/S构架,属于分布式架构的一种.也就是使用云+端的模式.阿里云提供的有PaaS和IaaS服务,这样比较传统开发,节约了总体拥有成本,简化了开发和部署. 解决方案二: 不自己写还能自动生成么- -?

求含有单元测试代码的ios版app

问题描述 求含有单元测试代码的ios版app 最近在学着写单元测试,终于摸到了xcTest的边,但是对于一个从来没有写过测试代码的人来说,突然写测试,有一种不知道如何下手的感觉 有人有iOS端的写了单元测试的项目吗,我想看看前辈们是怎么写测试的,好有个思路. 邮箱:huipaodetuzi@163.com 急,在线等.......

cocos2d-x如何将windows编好的程序生成ios平台app

问题描述 cocos2d-x如何将windows编好的程序生成ios平台app 如题,怎么跨平台,将windows编好的程序生成ios平台app 解决方案 不太懂,帮顶!不过据我所知,你是需要把源代码放到Mac里面,然后用Xcode重新编译一下的.大的地方不用改,可能需要修改一下链接库之类的东西,具体看你编译时遇到的问题了! 解决方案二: windows编好的程序 是什么语言编写的? 肯定不能直接放到xcode里面编译的吧? 可以考虑用Qt

“爱奇艺热聊”正式推出iOS平台App

8月6日,爱奇艺视频社交APP"爱奇艺热聊"正式推出iOS平台App,该产品是继奇谈和啪啪奇之后,爱奇艺在视频社交领域推出的又一款重要产品.用户可以通过"爱奇艺热聊"找到和自己有着同样观影兴趣的人,并通过文字.语音.投票等多种互动方式分享交流自己的看法.     过去,人们更习惯于和朋友面对面讨论自己感兴趣的影视节目,随着互联网的发展,这种讨论的核心阵地从线下转向线上,讨论的对象也从原来的周边好友变成了网络上的陌生同好.据悉,"爱奇艺热聊"从今年

Google Babel for iOS版或命名iOS Babel App

&http://www.aliyun.com/zixun/aggregation/37954.html">nbsp;   在I/O大会发布之前曾有谣传称Google将会整合旗下的聊天应用,推出 一款研发代号为"Babel"的统一界面信息服务应用, 不过在 大会上我们谷歌并未提到任何这个名词, 而是用Hangouts来整合旗下服务,不过最近又有 新的证据显示Google可能会在未来发布这样一款iOS应用,可以看到iOS平台上的Hangouts应用实际名称为&quo