Search Unity

  1. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  2. Unity 2017.2 is now released.
    Dismiss Notice
  3. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  6. Unity 2017.3 beta is now available for download.
    Dismiss Notice

Unity 2017.2.0b8 + .NET 4.6 + Firebase Scripting Runtime Websocket errors

Discussion in 'Experimental Scripting Previews' started by ItsLeeOwen, Jun 11, 2017.

  1. ItsLeeOwen

    ItsLeeOwen

    Joined:
    Jun 3, 2017
    Posts:
    11
    I'm looking forward to the .NET Scripting Runtime upgrade, and am seeing Websocket TLS errors coming from the Firebase C# Plugin. I'm not sure if this is ultimately a fix that will need to go into the firebase C# api, or unity.


    [Error] WebSocket: ws_0 - IOException during handshake
    System.IO.IOException: The authentication or decryption has failed. ---> System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: Invalid certificate received from server. Error code: 0x3
    at Mono.Security.Protocol.Tls.RecordProtocol.EndReceiveRecord (System.IAsyncResult asyncResult) [0x00040] in <59bcb3a41e31492f91d9513566444e88>:0
    at Mono.Security.Protocol.Tls.SslClientStream.SafeEndReceiveRecord (System.IAsyncResult ar, System.Boolean ignoreEmpty) [0x00000] in <59bcb3a41e31492f91d9513566444e88>:0
    at Mono.Security.Protocol.Tls.SslClientStream.NegotiateAsyncWorker (System.IAsyncResult result) [0x00071] in <59bcb3a41e31492f91d9513566444e88>:0
    --- End of inner exception stack trace ---
    at Mono.Security.Protocol.Tls.SslClientStream.EndNegotiateHandshake (System.IAsyncResult result) [0x0003b] in <59bcb3a41e31492f91d9513566444e88>:0
    at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (System.IAsyncResult asyncResult) [0x0000c] in <59bcb3a41e31492f91d9513566444e88>:0
    --- End of inner exception stack trace ---
    at Mono.Security.Protocol.Tls.SslStreamBase.EndRead (System.IAsyncResult asyncResult) [0x00057] in <59bcb3a41e31492f91d9513566444e88>:0
    at Mono.Net.Security.Private.LegacySslStream.EndAuthenticateAsClient (System.IAsyncResult asyncResult) [0x00011] in <f044fe2c9e7e4b8e91984b41f0cf0b04>:0
    at Mono.Net.Security.Private.LegacySslStream.AuthenticateAsClient (System.String targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, System.Security.Authentication.SslProtocols enabledSslProtocols, System.Boolean checkCertificateRevocation) [0x0000e] in <f044fe2c9e7e4b8e91984b41f0cf0b04>:0
    at Mono.Net.Security.Private.LegacySslStream.AuthenticateAsClient (System.String targetHost) [0x00007] in <f044fe2c9e7e4b8e91984b41f0cf0b04>:0
    at Mono.Net.Security.Private.MonoSslStreamImpl.AuthenticateAsClient (System.String targetHost) [0x00006] in <f044fe2c9e7e4b8e91984b41f0cf0b04>:0
    at System.Net.Security.SslStream.AuthenticateAsClient (System.String targetHost) [0x00006] in <f044fe2c9e7e4b8e91984b41f0cf0b04>:0
    at Firebase.Database.Internal.TubeSock.WebSocket.RunReader () [0x000bf] in <cf10b78eead54f39b6cbec497dcd100b>:0
    UnityEngine.Debug:LogError(Object)
    Firebase.FirebaseHandler:LogMessage(LogLevel, String)
    Firebase.Unity.UnityLoggingService:LogMessage(LogLevel, String)
    Firebase.Database.Internal.Logging.DefaultLogger:Error(String, String)
    Firebase.Database.Internal.Logging.DefaultLogger:OnLogMessage(Level, String, String, Int64)
    Firebase.Database.Internal.Logging.LogWrapper:Error(String, Exception)
    Firebase.Database.Internal.TubeSock.WebSocket:LogError(String, Exception)
    Firebase.Database.Internal.TubeSock.
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    2,727
    Can you submit a bug report with this project? This certificate errors are notorious finicky, so I would like to be able to investigate it here.
     
  3. ItsLeeOwen

    ItsLeeOwen

    Joined:
    Jun 3, 2017
    Posts:
    11
    @JoshPeterson I submitted a report to Unity + Firebase. The Firebase team says they are unable to reproduce, I'm not 100% sure the support staff are familiar with the steps involved to run Unity with the newer runtime so I made a screen-recording of the issue & git repo.

    https://github.com/ItsLeeOwen/Unity2017-Firebase
     
    Qbit86 likes this.
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    2,727
    Thanks, I saw the bug report come in today, so we will investigate it.
     
  5. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    2,727
    Thanks! We will continue to investigate on our side as well. If you hear from them that it is corrected, please reply via the bug report so that we will be aware. Thanks!
     
  6. nventimiglia

    nventimiglia

    Joined:
    Sep 20, 2011
    Posts:
    149
    This error comes from not web-socket client library. The mono implementations for a lot of these things do not implement the TLS handshake correctly.... and are buggy in general. There are a few solutions for this problem. If you search Xamarin bugzilla you will see a few people crying over this bug (including myself).

    1. Change the websocket transport. All of them suck.
    2. Disable SSL / TLS
    3. Rewrite mono to correctly support SSL.
    4. Use a native websocket and use a bridge to bring it into unity.
    The last step completely side steps mono, and thus works the best. I would contact firebase and have them fix the issue.
     
  7. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    2,727
    While we don't have a good solution for TLS with Mono at the moment, it is an active area of development. So longer-term, I would expect better support for this kind of thing in future Unity releases.
     
  8. ItsLeeOwen

    ItsLeeOwen

    Joined:
    Jun 3, 2017
    Posts:
    11
    With Unity 2017.2.0b8 + .NET4.6 + Firebase Unity SDK 4.0.3 ( https://firebase.google.com/support/release-notes/unity ) there is some improvement, the Websocker error is not thrown, and instead a workaround log is output to the console.

    But FirebaseDatabase doesn't seem to return either an err or result following the Firebase example code ( https://firebase.google.com/docs/database/unity/retrieve-data#read_data_once ).

    Using workaround for .NET 4.6 certificate bug.
    UnityEngine.Debug:Log(Object)
    Firebase.FirebaseHandler:LogMessage(LogLevel, String)
    Firebase.Unity.UnityLoggingService:LogMessage(LogLevel, String)
    Firebase.Unity.InstallRootCerts:.ctor()
    Firebase.Unity.InstallRootCerts:.cctor()
    Firebase.Unity.UnityPlatformServices:Install(GameObject)
    Firebase.FirebaseHandler:<Create>m__0()
    Firebase.FirebaseApp:TranslateDllNotFoundException(Action)
    Firebase.FirebaseHandler:Create()
    Firebase.FirebaseApp:get_DefaultInstance()
     
  9. ItsLeeOwen

    ItsLeeOwen

    Joined:
    Jun 3, 2017
    Posts:
    11
  10. ItsLeeOwen

    ItsLeeOwen

    Joined:
    Jun 3, 2017
    Posts:
    11
  11. bcjordan

    bcjordan

    Joined:
    Sep 23, 2013
    Posts:
    15
    Is this specific to iOS / Android? Or is there support for standalone (Windows / OS X) now?