由于应用传输安全性,Parse-Server未下载PFFile

时间:2016-02-21 04:13:26

标签: ios mongodb parse-platform app-transport-security parse-server

我正在从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?

2 个答案:

答案 0 :(得分:3)

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

通过这种方式,您不需要完全禁用ATS(这是您指出的不好的做法),但您的应用仍会允许来自您网域的不安全电话。

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

App Transport Security Settings

Exception Domains

这是Info.plist应该看到的结果:

Your domain

答案 1 :(得分:0)

Apple在2016年WWDC上宣布,从2017年开始,它将不再接受带有App Transport Security设置解决方案的应用程序。