传输安全阻止了明文 HTTP [英] Transport security has blocked a cleartext HTTP

查看:30
本文介绍了传输安全阻止了明文 HTTP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 info.plist 中进行什么设置才能根据以下错误消息启用 HTTP 模式?

What setting do I need to put in my info.plist to enable HTTP mode as per the following error message?

传输安全已阻止明文 HTTP (http://) 资源加载,因为它不安全.可以通过配置临时异常您应用的 Info.plist 文件.

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.

假设我的域是 example.com.

推荐答案

如果您使用的是 Xcode 8.0+ 和 Swift 2.2+ 甚至 Objective C:

If you are using Xcode 8.0+ and Swift 2.2+ or even Objective C:

如果你想允许任何站点的 HTTP 连接,你可以使用这个键:

If you want to allow HTTP connections to any site, you can use this keys:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

如果您知道要连接到哪些域:

If you know which domains you will connect to add:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>example.com</key>
        <dict>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSIncludesSubdomains</key>
            <true/>
        </dict>
    </dict>
</dict>

这篇关于传输安全阻止了明文 HTTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆