Apple 宣布了适用于 iOS 9 和 OSX 10.11 El Capitan 的“App Transport Security”。“<a href="https://developer.apple.com/library/prerelease/ios/releasenotes/General/WhatsNewIniOS/Articles/iOS9.html" rel="nofollow noreferrer">iOS 中的新增功能”iOS 指南9 解释:
应用传输安全 (ATS) 允许应用将声明添加到其 Info.plist 文件中,该文件指定需要与其进行安全通信的域。ATS 可防止意外泄露,提供安全的默认行为,并且易于采用。无论您是创建新应用还是更新现有应用,都应尽快采用 ATS。
如果我们想删除或禁用 ATS 意味着我们只想使用 HTTP,那么我们将在.plist
文件中输入如下:
<key>NSAppTransportSecurity</key>
<dict>
<!--Include to allow all connections (DANGER)-->
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
如果我们的域在 HTTPS 中,我们将在.plist
文件中输入如下:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>yourserver.com</key>
<dict>
<!--Include to allow subdomains-->
<key>NSIncludesSubdomains</key>
<true/>
<!--Include to allow HTTP requests-->
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<!--Include to specify minimum TLS version-->
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>
问题是:
如果我的应用程序仅在 HTTP 之类的 Web 服务上运行。我想使用 HTTPS 域,如谷歌地图或 Facebook 登录等。或者像一个 web 服务这样的东西是用于 HTTPS 域的。
那么我们如何将.plist
文件中的两者结合起来呢?