gpt4 book ai didi

ios - 我们如何在一个应用程序中同时使用 HTTP 和 HTTPS ATS(应用程序传输安全)?

转载 作者:搜寻专家 更新时间:2023-10-31 22:14:51 25 4
gpt4 key购买 nike

Apple announced “App Transport Security” for iOS 9 and OSX 10.11 El Capitan. The “What’s New in iOS” guide for iOS 9 explains:

App Transport Security (ATS) lets an app add a declaration to itsInfo.plist file that specifies the domains with which it needs securecommunication. ATS prevents accidental disclosure, provides securedefault behavior, and is easy to adopt. You should adopt ATS as soonas possible, regardless of whether you’re creating a new app orupdating an existing one.

如果我们想删除或禁用 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 等网络服务上运行。我想使用 HTTPS 域,例如 google map 或 Facebook 登录等。或者任何类似一个网络服务的东西都适用于 HTTPS 域。

那么我们如何在.plist 文件中合并这两个东西?

最佳答案

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

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

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

希望这对您有所帮助!

关于ios - 我们如何在一个应用程序中同时使用 HTTP 和 HTTPS ATS(应用程序传输安全)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32774138/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com