问题描述
在 iOS 9 上排除 ATS 对我不起作用.
excluding ATS on iOS 9 doesn't work for me.
我有一个没有域名(只有 IP 地址)和 SSL 证书的测试服务器(所以它是 HTTP 而不是 HTTPS)
I have a test server which has no domain name (IP address only) and no SSL certificate (so it is HTTP and not HTTPS)
尝试过:
<key>52.24.145.252</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
但我仍然收到错误:
App 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.
我做错了什么?
推荐答案
您需要将 NSAppTransportSecurity
字典添加到您的 info.plist
.然后加NSAllowsArbitraryLoads
该字典的键并将布尔值设置为 YES
.
You need to add NSAppTransportSecurity
dictionary to your info.plist
. Then addNSAllowsArbitraryLoads
key to that dictionary and set the boolean value to YES
.
更新
自 2017 年 1 月起,如果您使用上述方法选择退出 ATS,您需要在将您的应用提交到 AppStore 时向 Apple 提供理由.
From 2017 January, if you are using the above mentioned method for opting-out from ATS you need to provide a justification to Apple while submitting your app to AppStore.
这篇关于NSExceptionAllowsInsecureHTTPLoads 不适用于 IP 地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!