iOS 10,Firebase和PhoneGap - 获取SSL错误 [英] iOS 10, Firebase, and PhoneGap - Getting SSL error

查看:360
本文介绍了iOS 10,Firebase和PhoneGap - 获取SSL错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PhoneGap为Android和iOS开发一个跨平台的应用程序。访问 auth()和验证用户在两个平台上都能正常工作,我可以在Firebase控制台中验证。



但是,访问数据库只适用于Android。当我在iOS中运行相同的代码时,它给了我:

 加载资源失败:出现SSL错误,不能建立到服务器的安全连接。 

我的CSP包含 firebaseio.com 及其子域,就像 config.xml 一样。我还可以验证Xcode中的ATS是否已启用,并在模拟器中运行PhoneGap应用程序时正确生成。



通过代码示例:

  var adminRef = firebase.database()。ref('/ admin /'); 
console.log('here');
console.log(adminRef);
adminRef.on('value',function(snapshot){
//做结果...
}

引发SSL错误,即使在配置中禁用APP Transport Security也不允许连接通过。



我错过了什么吗?一切都是最新的。

解决方案

访问ios 10中的Firebase数据库需要禁用前向保密功能。



在plist中,这意味着:

 < key> firebaseio.com< / key> 
< dict>
< key> NSIncludesSubdomains< / key>
< ;
< / dict>
< / code>
< key>
< key> NSExceptionRequiresForwardSecrecy< / key>
< pre>

或者在Cordova / phonegap中,您可以在config.xml中禁用它:

 < access origin =https://*.firebasei o.comsubdomains =truerequires-forward-secrecy =false/> 

在我的情况下,我开始收到一个关于不在我的CSP中的websocket调用的错误。这是,但它不工作。在我的config.xml中,我还必须添加:

 < access origin =wss://*.firebaseio。 comsubdomains =true/> 

现在在config.xml文件中,一切都可以正常工作。
希望这可以节省别人的头痛。


I'm using PhoneGap to develop a cross-platform app for both Android and iOS. Accessing auth() and authenticating users works correctly on both platforms, which I can verify in the Firebase console.

However, accessing the database only works in Android. When I run the same code in iOS, it gives me:

"Failed to load resource: An SSL error has occurred and a secure connection to the server cannot be made."

My CSP includes firebaseio.com and its subdomains, as does the config.xml. I can also verify that the ATS in Xcode is enabled, and it is generated properly when I go to run the PhoneGap app in the simulator.

By way of code example:

var adminRef = firebase.database().ref('/admin/');
    console.log('here');
    console.log(adminRef);
    adminRef.on('value', function(snapshot) {
        //do stuff with the result...
}

Throws the SSL error. Even disabling APP Transport Security in the config (and thus the plist) doesn't allow the connection to go through.

Am I missing something? Everything is up to date.

解决方案

Ok, I figured it out. Accessing the Firebase Database in ios 10 requires you to disable forward secrecy.

In just the plist, this means:

    <key>firebaseio.com</key>
    <dict>
      <key>NSIncludesSubdomains</key>
      <true/>
      <key>NSExceptionRequiresForwardSecrecy</key>
      <false/>
    </dict>

Or in Cordova/phonegap, you can disable it in config.xml:

<access origin="https://*.firebaseio.com" subdomains="true" requires-forward-secrecy="false"/>

In my case, I then began getting an error about a websocket call that wasn't in my CSP. It was, but it wasn't working. In my config.xml, I also had to add:

<access origin="wss://*.firebaseio.com" subdomains="true"/>

Now everything is okay in config.xml file and build works. Hope this saves someone else a headache.

这篇关于iOS 10,Firebase和PhoneGap - 获取SSL错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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