3

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文件中的两者结合起来呢?

4

1 回答 1

5

如果您的应用程序(例如第三方网络浏览器)需要加载任意内容,Apple 提供了一种完全禁用 ATS 的方法,但我怀疑您最好谨慎使用此功能:

完全禁用ATS只需在您的Info.plist文件中包含以下内容,然后您就可以在一个应用程序HTTP中使用HTTPS

<key>NSAppTransportSecurity</key>
<dict>
      <!--Include to allow all connections (DANGER)-->
      <key>NSAllowsArbitraryLoads</key>
      <true/>
</dict>

希望这可以帮助!

于 2015-09-25T05:06:43.573 回答