4

我正在从 Parse 的后端迁移到 Heroku 和 MongoDB 上的 Parse 服务器。

通过这个新的后端更改,我让一切工作顺利(包括加载 PFFiles),但是,我现在在添加FACEBOOK_APP_ID参数后遇到错误,但这可能不是原因。

每当我尝试加载PFFile(图像)时,我都会在日志中收到以下消息:

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.
2016-02-20 19:55:48.242 HoopMaps[35976:682425] [Error]: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection. (Code: 100, Version: 1.12.0)
2016-02-20 19:55:48.243 HoopMaps[35976:682425] [Error]: Network connection failed. Making attempt 1 after sleeping for 1.730434 seconds.
2016-02-20 19:55:50.137 HoopMaps[35976:682402] [Error]: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection. (Code: 100, Version: 1.12.0)
2016-02-20 19:55:50.138 HoopMaps[35976:682402] [Error]: Network connection failed. Making attempt 2 after sleeping for 3.460868 seconds.
2016-02-20 19:55:53.857 HoopMaps[35976:682403] [Error]: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection. (Code: 100, Version: 1.12.0)
2016-02-20 19:55:53.857 HoopMaps[35976:682403] [Error]: Network connection failed. Making attempt 3 after sleeping for 6.921736 seconds.
2016-02-20 19:56:01.162 HoopMaps[35976:682821] [Error]: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection. (Code: 100, Version: 1.12.0)
2016-02-20 19:56:01.162 HoopMaps[35976:682821] [Error]: Network connection failed. Making attempt 4 after sleeping for 13.843473 seconds.
2016-02-20 19:56:15.264 HoopMaps[35976:682785] [Error]: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection. (Code: 100, Version: 1.12.0)

虽然我可以禁用 ATS,但这是不好的做法,我更喜欢 HTTPS。此外,错误代码是“100”,但我可以连接到我的服务器并检索对象和用户数据。

如何在保留 HTTPS 的同时使用 Parse-server 加载 PFFiles?

4

2 回答 2

3

最好的办法是为您的 API 获取 SSL 证书,但如果不可能,暂时的解决方法是将您的域添加为 ATS 的例外。

这样,您无需完全禁止 ATS(正如您所指出的那样,这是一种不好的做法),但您的应用仍将允许来自您的域的不安全调用。

为此,请打开 Info.plist 文件并添加App Transport Security Settings. 然后选择Exception Domains您的域并将其添加到列表中。

应用传输安全设置

异常域

这就是你Info.plist应该如何看待最后:

您的域

于 2016-02-21T05:05:27.393 回答
0

Apple 在 WWDC 2016 上宣布,从 2017 年开始,它将不再接受具有 App Transport Security Setting 变通方案的 App。

于 2016-07-05T14:59:39.600 回答