【问题标题】:Could not fetch JSON URL and some error show below, App Transport Security has blocked a cleartext HTTP (http://)无法获取 JSON URL 并在下面显示一些错误,App Transport Security 已阻止明文 HTTP (http://)
【发布时间】:2016-06-09 07:23:16
【问题描述】:

错误##

2016-06-09 12:31:56.252 chamber_of_commerce[2202:69165] 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.

首先在 Xcode 5.2 上创建项目,今天重新打开 xcode7.2。这个问题是不是这样?

我使用了 Xcode7.2 并使用了所有方法,但没有解决我的问题。请帮助我如何在我的项目中使用 Web 服务。我尝试了很多次,但没有使用任何方法。请解决我的问题。

I used non-lazy method, but it didn't work. Followings are my tries.

first,
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
    <key>www.edutimeapp.com</key>
    <dict>
        <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
        <true/>
        <key>NSTemporaryExceptionMinimumTLSVersion</key>
        <string>TLSv1.1</string>
        <key>NSIncludesSubdomains</key>
        <true/>
    </dict>
</dict>
  and second,
 <key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
    <key>www.edutimeapp.com</key>
    <dict>
        <key>NSExceptionAllowsInsecureHTTPLoads</key>
        <true/>
        <key>NSExceptionMinimumTLSVersion</key>
        <string>TLSv1.1</string>
        <key>NSIncludesSubdomains</key>
        <true/>
    </dict>
</dict>
Finally, I used lazy method.
 <key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>

【问题讨论】:

  • @neha 使用了所有方法,但没有工作并显示相同的错误。
  • 首先在 Xcode 5.2 上创建项目,今天重新打开 xcode7.2。这个问题是不是这样?

标签: objective-c json xcode info.plist


【解决方案1】:

试试这个。

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>www.edutimeapp.com</key>
        <dict>
            <key>NSExceptionMinimumTLSVersion</key>
            <string>TLSv1.1</string>
            <key>NSExceptionRequiresForwardSecrecy</key>
            <false/>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSIncludesSubdomains</key>
            <true/>
        </dict>
    </dict>
</dict>

添加,

<key>NSAllowsArbitraryLoads</key>
      <false/>

NSAllowsArbitraryLoads 必须是 false,因为它不允许所有 insecure 连接,但例外列表允许连接到没有 https 的某些域。

【讨论】:

  • 我正在尝试您的代码,但显示相同的错误。如何解决错误?
猜你喜欢
  • 2016-01-24
  • 2016-04-17
  • 2015-11-30
  • 2015-12-18
  • 1970-01-01
  • 2015-11-05
  • 2015-12-11
  • 2018-12-24
  • 2016-11-26
相关资源
最近更新 更多