Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Unity 2017.1 - TLS 1.2 still not working with .NET 4.6

Discussion in 'Experimental Scripting Previews' started by Zocker1996, Aug 9, 2017.

  1. Zocker1996

    Zocker1996

    Joined:
    Jan 12, 2015
    Posts:
    20
    Using the following code with Scripting Runtime Version .NET 4.6

    Code (CSharp):
    1. using System.Net.Security;
    2. using System.Net.Sockets;
    3. using UnityEngine:
    4. public class TlsTest : MonoBehaviour{
    5.     void Start(){
    6.         TcpClient client = new TcpClient ();
    7.         client.Connect ("localhost", 56782);
    8.         SslStream ssl = new SslStream (client.GetStream());
    9.         ssl.AuthenticateAsClient ("localhost");
    10.     }
    11. }
    gives me this error:
    Code (CSharp):
    1. Assets/Main.cs(8,19): error CS0012: The type `Mono.Security.Interface.IMonoSslStream' is defined in an assembly that is not referenced. Consider adding a reference to assembly `Mono.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756'

    Using the code with .NET 3.5 is fine BUT .NET 3.5 is missing TLS 1.2 (4.6 should have it).
    Since I need TLS 1.2 using .NET 3.5 isn't a solution.

    I searched for the needed DLL, found it here (https://github.com/danzel/Npgsql/blob/master/lib/Mono.Security/4.0/Mono.Security.dll) and added a reference.
    This gives me this error:
    Code (CSharp):
    1. Assets/Main.cs(8,19): error CS7069: Reference to type `Mono.Security.Interface.IMonoSslStream' claims it is defined assembly `Mono.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756', but it could not be found
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Actually when we build Mono for Unity we don't include TLS 1.2 support, as how it is supported and implemented varies across platforms. We're currently working on a common backend which will support TLS 1.2, but it is not ready yet.

    So the new Mono runtime has the same TLS support as the old Mono runtime - which is to say - not much. We're working to improve that.
     
    MechEthan and BlackPete like this.
  3. Zocker1996

    Zocker1996

    Joined:
    Jan 12, 2015
    Posts:
    20
    Thanks for the answer!
    For my next iOS and Android project TLS1.2 will be mandatory.
    Do you think your are able to implement it till the end of the year?
    If not, I'm going to use the platforms native SSL Engines and build a workaround, but an out of box unity would be much cooler :)
     
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    I don't have a timetable, so I think that you should stick to the platform native SSL engines for the time being to be safe.
     
  5. Tazadar66

    Tazadar66

    Joined:
    Aug 27, 2013
    Posts:
    57
    Hello is it still the case for 2017.2 version ?
     
  6. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Yes, we have not completed TLS support for Unity 2017.2. Using platform native SSL libraries is still the best option.
     
  7. Tazadar66

    Tazadar66

    Joined:
    Aug 27, 2013
    Posts:
    57
    Thanks for the answer!

    Still no ETA I suppose?

    I will just make a PC version for now then....
     
  8. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Yes, no ETA unfortunately yet.
     
  9. enne30

    enne30

    Joined:
    Feb 1, 2017
    Posts:
    4
    Hi,

    any news regarding this issue?

    Thank you.
     
  10. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    We don't have any news yet. We're hoping to get TLS 1.2 support in 2018.1 before the end of the beta period, but it is not ready yet.
     
    Seraphic572 and enne30 like this.
  11. Bhearus

    Bhearus

    Joined:
    Aug 17, 2013
    Posts:
    27
    Thank you for this update, I have been looking forward to TLS 1.2 support for years. Will that support allow for System.Net.Protocol to be used instead of mono or will it be a custom build from Unity that allows TLS 1.2 encryption over sockets to be possible on iOS? Most of my back-end server uses custom asynchronous socket management, but the TLS limitations prevents me from using TLS 1.2.

    I prefer direct socket management as I have full control of who and what is connecting to my server allowing me to isolate sensitive data and protect it better. Thus, i don't use web based HTTPS calls, unless I have to. For example, I know UnityWebRequest handles TLS 1.2 just fine, but, I don't use HTTPS calls which build and tear down the socket, I maintain a socket connection with the Socket class.

    I would be open to moving to TPL if it supported TLS12 on all of the platforms, but I would like to maintain that socket level control.
     
  12. andreasreich

    andreasreich

    Unity Technologies

    Joined:
    Sep 24, 2017
    Posts:
    55
    We will have TLS1.2 on all platforms in 2018.2 via UnityWebRequest, SSLStream and other higher level .Net45 classes like HttpClient.
    As far as I know, UnityWebRequest does not support TLS on all platforms currently.

    I'm not sure though what you mean with System.Net.Protocol. Also, I don't know what TPL is in this context, can give a few more details maybe? Thanks! :)
     
  13. Bhearus

    Bhearus

    Joined:
    Aug 17, 2013
    Posts:
    27
    UnityWebRequest is more focused on website, webserver based HTTP requests. The Socket Class is using Mono for the TLS security, it's outdated, that's what needs to be updated. The System.Net.Portocol is just related, it's where the enum is for Tls12.

    TPL is just the Task Parallel Library, it's another way to implement an asynchronous socket server, though I don't know a lot about it, I believe it wraps around the Socket class at a higher level. I would hope Unity has discussed in detail how to get the Socket class up to speed by now as I have brought this up for years....
     
  14. andreasreich

    andreasreich

    Unity Technologies

    Joined:
    Sep 24, 2017
    Posts:
    55
    If you're talking about System.Net.Sockets.Socket, it is not using any SSL/TLS at all. After all, it is just a socket. As such it is not aware of any higher level protocols and operates solely on UDP/TCP. You can of course use Socket with SSLStream though.

    What is it that you are missing with the Socket? I'm fairly new here, so I think missed any concerns about it.
     
  15. Bhearus

    Bhearus

    Joined:
    Aug 17, 2013
    Posts:
    27
  16. andreasreich

    andreasreich

    Unity Technologies

    Joined:
    Sep 24, 2017
    Posts:
    55
    That one will be fixed in 2018.2, code for this is on the way to our main development line but sadly won't make it to 2018.1
     
    enne30 and Bhearus like this.
  17. Bhearus

    Bhearus

    Joined:
    Aug 17, 2013
    Posts:
    27
    Ok, well I am just glad it's on the radar.
     
  18. Bhearus

    Bhearus

    Joined:
    Aug 17, 2013
    Posts:
    27
  19. andreasreich

    andreasreich

    Unity Technologies

    Joined:
    Sep 24, 2017
    Posts:
    55
    @Bhearus: I replied on your issue via fogbugz, but here again for everyone to read:
    Your specific error is caused by accessing one of the SslStream properties that are on Mono's "internal todo" list. Means that we're are not getting them in our backend at all yet. We could go ahead and implement them ourselves, but that would mean conflicts in the near future thus making it harder for us to keep things up to date.
    So I'm sorry to say that we won't fix this for 2018.2
    Affected are:
    • CipherStrength
    • HashStrength
    • KeyExchangeStrength
    • CheckCertRevocationStatus
    See:
    https://github.com/mono/mono/blob/m...et.Security/MobileAuthenticatedStream.cs#L879
    (or respectively our fork https://github.com/Unity-Technologi...et.Security/MobileAuthenticatedStream.cs#L879)
     
    Bhearus likes this.
  20. Bhearus

    Bhearus

    Joined:
    Aug 17, 2013
    Posts:
    27
    I'm fine with a work around for now, because until I can do this, I can't move to 2018.1. I don't mind correcting it once the fix is in.
     
  21. Bhearus

    Bhearus

    Joined:
    Aug 17, 2013
    Posts:
    27
    I wanted to add, I really appreciate your responses. The communication is great. I know I have been pushing this issue for a while now and I am a bit of a pain about it. I am one of those developers who believes Unity can do MUCH more than make video games, and have demonstrated as much in the past few years. One of the key portions of that expanded development involves protecting sensitive data through TLS encryption. HIPAA compliance, PCI, PA-DSS all require the TLS v1.2 for both financial and medical industries, as well as others.

    Thank you again for the communication!
     
    andreasreich likes this.
  22. andreasreich

    andreasreich

    Unity Technologies

    Joined:
    Sep 24, 2017
    Posts:
    55
    Thank you, really nice to hear that :)

    Just to clarify, all the new TLS bits and pieces are about 2018.2! There is nothing we did in 2018.1 except maybe "accidentally" by upgrading Mono. No guarantees on anything TLS in 2018.1


    As for workarounds: The project you attached to the bugticket (which looked oddly familiar to me ;)) works fine for me in 2018.2 once you comment out all the lines where it logs the properties I've mentioned. (small disclaimer: Haven't fully tested myself yet since the project looked so familiar and the exception seemed straight-forward to me)
     
    Cromfeli likes this.
  23. Cromfeli

    Cromfeli

    Joined:
    Oct 30, 2014
    Posts:
    202
    Any update on this progress or any issues popping up for limitations or everything good for 2018.2?
     
  24. Bhearus

    Bhearus

    Joined:
    Aug 17, 2013
    Posts:
    27
    I don’t think it will work until 2018.3. Eagerly waiting for the beta of that version. Until then I’m stuck in 2017 and don’t have the interest to rebuild mono to comment out lines.
     
    Last edited: Jun 19, 2018
  25. Bhearus

    Bhearus

    Joined:
    Aug 17, 2013
    Posts:
    27
    Well it works with 2018.2b10, in the QA test I sent in, but not in my project. So bizarre.
     
  26. Bhearus

    Bhearus

    Joined:
    Aug 17, 2013
    Posts:
    27
    I got it, it works. yay! Will do a wireshark test later, but the protocols are set to Tls12 so that's good!
     
  27. Glader

    Glader

    Joined:
    Aug 19, 2013
    Posts:
    456
    Does that mean the public 2018.2.0b10 has working TLS support for Mono/net4.x/netstandard2.0? Can we expect this support to make it to the release candidates or final releases?

    edit: I ended up with TlsException: Handshake failed - error code: UNITYTLS_INTERNAL_ERROR, verify result: UNITYTLS_X509VERIFY_FATAL_ERROR

    edit2: That was with SecurityProtocolType.Tls. Switching to SecurityProtocolType.Tls12 and finally things work.
     
    Last edited: Jul 2, 2018
  28. Bhearus

    Bhearus

    Joined:
    Aug 17, 2013
    Posts:
    27
    Yes, I was able to get it working. I had to revaluate how I was exporting my certificates but after that my servers and clients started talking perfectly.

    I don’t know about the release question though. I assume it will, but I am not 100%.
     
  29. andreasreich

    andreasreich

    Unity Technologies

    Joined:
    Sep 24, 2017
    Posts:
    55
    Yep, everything TLS1.2 will land in the 2018.2 release. Also, all bug fixes for TLS things that were reported during the beta phase are making it to the final version :)
     
    Last edited: Jul 7, 2018
  30. andreasreich

    andreasreich

    Unity Technologies

    Joined:
    Sep 24, 2017
    Posts:
    55
    Yeah, it's a .Net thing, the default everywhere is SecurityProtocolType.Tls
    A bit sad though that we give out such a poor error message, I'll make a note to check if that can be fixed with reasonable effort.
     
  31. Bhearus

    Bhearus

    Joined:
    Aug 17, 2013
    Posts:
    27
    Hey, if you get a chance can you check out FrogBugz ticket #1057764. It's related to the WriteCallback, InvalidOperationException: invalid nested call. I submitted the bug this morning.
     
  32. andreasreich

    andreasreich

    Unity Technologies

    Joined:
    Sep 24, 2017
    Posts:
    55
    Just for for everyone else following this thread: This is an expected error for attempting interleaved asynchronous write calls on SslStream like BeginWrite and no bug in Unity. Using this advice Bhearus was able to fix the issue in his project.
    So everything looks good for TLS in 2018.2 so far :)
     
    Last edited: Jul 14, 2018
    remy_rm, Cromfeli and r618 like this.
  33. jguerra

    jguerra

    Joined:
    Jul 2, 2012
    Posts:
    3
    Hello

    I'm having an issue sending emails withing Unity and I think it might be relevant for this thread.
    Using 2017.17f1 emails were sent properly in Editor on both Windows and OSX but not working on iOS (couldn't quite figure out why but I think it had to do with stripping of libraries when building to IL2CPP).

    Nevertheless, we have updated the project to use 2018.2.2f1 and now emails are not even working in editor on either platform.

    This is the error I get:

    emailerrors.png

    This is the code I'm using (slightly edited to post here):

    Code (CSharp):
    1. public void SendEmail(string email, string password, Action<Error> callback = null) {
    2.         _emailSentCallback = callback;
    3.  
    4.         _mailMessage = new MailMessage {
    5.             From = new MailAddress(_fromEmail),
    6.             Subject = "subject",
    7.             Body = "body"
    8.         };
    9.  
    10.         _mailMessage.To.Add(email);
    11.  
    12.         SmtpClient smtpServer = new SmtpClient("smtp.office365.com") {
    13.             Port = 587,
    14.             EnableSsl = true,
    15.             UseDefaultCredentials = false,
    16.             DeliveryMethod = SmtpDeliveryMethod.Network,
    17.             Credentials = new System.Net.NetworkCredential(_username, _password) as ICredentialsByHost
    18.         };
    19.  
    20.         ServicePointManager.ServerCertificateValidationCallback = delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
    21.      
    22.         smtpServer.SendCompleted += new SendCompletedEventHandler(EmailSentCallback);
    23.         smtpServer.SendAsync(_mailMessage, _uniqueToken);
    24.     }
    I've also tried adding this line before calling the function with no sucess.
    System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;


    Any idea what it might be?
    Cheers.
     
  34. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    I'm not sure about the cause of this issue. However, it looks like a bug (since it worked in earlier versions of Unity). Can you submit a bug report?
     
  35. jguerra

    jguerra

    Joined:
    Jul 2, 2012
    Posts:
    3
    Thanks for the reply.
    I've just submitted a bug report. Here's the case id: 1069532

    When building the test project, I've stumbled upon the fact that it works if the scripting runtime version is .NET 3.5 but not with .NET 4.0.

    Unfortunately we're using async Tasks so we kind of need to use 4.0.
     
  36. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Thanks, we'll investigate this.
     
    Cromfeli likes this.
  37. jguerra

    jguerra

    Joined:
    Jul 2, 2012
    Posts:
    3
    Got a reply with a alpha build to test it out and it works. :)
    Awesome response time from the Unity team.

    The fix will be released with Unity 2017.3.0.
     
  38. aurelien-morel-ubiant

    aurelien-morel-ubiant

    Joined:
    Sep 27, 2017
    Posts:
    275
    I think you would say 2018.3 but great to hear that !
     
  39. cryptoforge

    cryptoforge

    Joined:
    Jan 21, 2015
    Posts:
    60
    Can’t establish a secure websocket connection using websockets-sharp because Tls 1.2 support is non existent on Unity macos. Total BS... $&%#!
     
    Ekwav likes this.
  40. andreasreich

    andreasreich

    Unity Technologies

    Joined:
    Sep 24, 2017
    Posts:
    55
    @playent Can you please elaborate? What errors are you getting exactly? TLS1.2 should work in 2018.2 with .Net4
     
  41. EduardMatveev

    EduardMatveev

    Joined:
    Mar 10, 2015
    Posts:
    2
    Hi all
    I have exact problem this is my log
    Unity3d 2018.2.4f1, Mono .NET 4x .NET Standart 2.0, Android 4.4.2 GT-N7100, custom WebSocket with System.Net.Security.SslStream
    Code (csharp):
    1.  
    2. 08-21 13:24:39.466: E/dalvikvm(23605): VM aborting
    3. 08-21 13:24:39.466: E/CRASH(23605): signal 6 (SIGABRT), code -6 (?), fault addr --------
    4. 08-21 13:24:39.466: E/CRASH(23605): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    5. 08-21 13:24:39.466: E/CRASH(23605): Build fingerprint: 'samsung/t03gxx/t03g:4.4.2/KOT49H/N7100XXUFNE1:user/release-keys'
    6. 08-21 13:24:39.466: E/CRASH(23605): Revision: '11'
    7. 08-21 13:24:39.466: E/CRASH(23605): pid: 23605, tid: 23672, name: Thread Pool Wor  >>> com.project.app <<<
    8. 08-21 13:24:39.466: E/CRASH(23605):     r0 00000000  r1 00005c78  r2 00000006  r3 00000000
    9. 08-21 13:24:39.466: E/CRASH(23605):     r4 00000006  r5 00000016  r6 00005c78  r7 0000010c
    10. 08-21 13:24:39.466: E/CRASH(23605):     r8 70489640  r9 70489658  sl 7048963c  fp 704895e8
    11. 08-21 13:24:39.466: E/CRASH(23605):     ip 70489638  sp 70489308  lr 4019f10d  pc 401ae18c  cpsr 70488f98
    12. 08-21 13:24:39.466: E/CRASH(23605): backtrace:
    13. 08-21 13:24:39.576: E/CRASH(23605):     #00  pc 0002218c  /system/lib/libc.so (tgkill+12)
    14. 08-21 13:24:39.576: E/CRASH(23605):     #01  pc 00013109  /system/lib/libc.so (pthread_kill+48)
    15. 08-21 13:24:39.576: E/CRASH(23605):     #02  pc 0001331d  /system/lib/libc.so (raise+10)
    16. 08-21 13:24:39.576: E/CRASH(23605):     #03  pc 00012053  /system/lib/libc.so
    17. 08-21 13:24:39.576: E/CRASH(23605):     #04  pc 00021a40  /system/lib/libc.so (abort+4)
    18. 08-21 13:24:39.576: E/CRASH(23605):     #05  pc 00046aab  /system/lib/libdvm.so (dvmAbort+78)
    19. 08-21 13:24:39.576: E/CRASH(23605):     #06  pc 00055855  /system/lib/libdvm.so (dvmDetachCurrentThread()+548)
    20. 08-21 13:24:39.576: E/CRASH(23605):     #07  pc 00049e8b  /system/lib/libdvm.so
    21. 08-21 13:24:39.576: E/CRASH(23605):     #08  pc 0003abc1  /system/lib/libdvm.so
    22. 08-21 13:24:39.576: E/CRASH(23605):     #09  pc 00b72984  /data/app-lib/com.project.app-2/libunity.so
    23. 08-21 13:24:39.576: E/CRASH(23605):     #10  il 00000057  at (wrapper managed-to-native) object.wrapper_native_0x617b8830 (Mono.Unity.UnityTls/unitytls_x509list_ref,byte*,Mono.Unity.size_t,Mono.Unity.UnityTls/unitytls_x509verify_callback,void*,Mono.Unity.UnityTls/unitytls_errorstate*) <0x00057>
    24. 08-21 13:24:39.576: E/CRASH(23605):     #11  il 00000117  at (wrapper delegate-invoke) <Module>.invoke_UnityTls/unitytls_x509verify_result_UnityTls/unitytls_x509list_ref_byte*_size_t_UnityTls/unitytls_x509verify_callback_void*_UnityTls/unitytls_errorstate* (Mono.Unity.UnityTls/unitytls_x509list_ref,byte*,Mono.Unity.size_t,Mono.Unity.UnityTls/unitytls_x509verify_callback,void*,Mono.Unity.UnityTls/unitytls_errorstate*) <0x00117>
    25. 08-21 13:24:39.576: E/CRASH(23605):     #12  il 00000503  at Mono.Unity.UnityTlsProvider.ValidateCertificate (Mono.Security.Interface.ICertificateValidator2,string,bool,System.Security.Cryptography.X509Certificates.X509CertificateCollection,bool,System.Security.Cryptography.X509Certificates.X509Chain&,Mono.Security.Interface.MonoSslPolicyErrors&,int&) [0x00188] in <7505e1ded68144da95fe0bd520bab178>:0
    26. 08-21 13:24:39.576: E/CRASH(23605):     #13  il 0000030b  at Mono.Net.Security.ChainValidationHelper.ValidateChain (string,bool,System.Security.Cryptography.X509Certificates.X509Certificate,System.Security.Cryptography.X509Certificates.X509Chain&,System.Security.Cryptography.X509Certificates.X509CertificateCollection,System.Net.Security.SslPolicyErrors) [0x000e6] in <7505e1ded68144da95fe0bd520bab178>:0
    27. 08-21 13:24:39.576: E/CRASH(23605):     #14  il 00000083  at Mono.Net.Security.ChainValidationHelper.ValidateChain (string,bool,System.Security.Cryptography.X509Certificates.X509Certificate,System.Security.Cryptography.X509Certificates.X509Chain,System.Security.Cryptography.X509Certificates.X509CertificateCollection,System.Net.Security.SslPolicyErrors) [0x00009] in <7505e1ded68144da95fe0bd520bab178>:0
    28. 08-21 13:24:39.576: E/CRASH(23605):     #15  il 0000007b  at Mono.Net.Security.ChainValidationHelper.ValidateCertificate (string,bool,System.Security.Cryptography.X509Certificates.X509CertificateCollection) [0x00017] in <7505e1ded68144da95fe0bd520bab178>:0
    29. 08-21 13:24:39.576: E/CRASH(23605):     #16  il 00000033  at Mono.Net.Security.MobileTlsContext.ValidateCertificate (System.Security.Cryptography.X509Certificates.X509CertificateCollection) [0x00012] in <7505e1ded68144da95fe0bd520bab178>:0
    30. 08-21 13:24:39.576: E/CRASH(23605):     #17  il 0000008f  at Mono.Unity.UnityTlsContext.VerifyCallback (Mono.Unity.UnityTls/unitytls_x509list_ref,Mono.Unity.UnityTls/unitytls_errorstate*) [0x0001a] in <7505e1ded68144da95fe0bd520bab178>:0
    31. 08-21 13:24:39.576: E/CRASH(23605):     #18  il 00000083  at Mono.Unity.UnityTlsContext.VerifyCallback (void*,Mono.Unity.UnityTls/unitytls_x509list_ref,Mono.Unity.UnityTls/unitytls_errorstate*) [0x00013] in <7505e1ded68144da95fe0bd520bab178>:0
    32. 08-21 13:24:39.576: E/CRASH(23605):     #19  il 000000d7  at (wrapper native-to-managed) Mono.Unity.UnityTlsContext.VerifyCallback (void*,Mono.Unity.UnityTls/unitytls_x509list_ref,Mono.Unity.UnityTls/unitytls_errorstate*) <0x000d7>
    33. 08-21 13:24:39.576: E/CRASH(23605):     #20  il 0000003b  at (wrapper managed-to-native) object.wrapper_native_0x61062e14 (Mono.Unity.UnityTls/unitytls_tlsctx*,Mono.Unity.UnityTls/unitytls_errorstate*) <0x0003b>
    34. 08-21 13:24:39.576: E/CRASH(23605):     #21  il 00000097  at Mono.Unity.UnityTlsContext.ProcessHandshake () [0x0001c] in <7505e1ded68144da95fe0bd520bab178>:0
    35. 08-21 13:24:39.576: E/CRASH(23605):     #22  il 000000fb  at Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake (Mono.Net.Security.AsyncOperationStatus) [0x0003e] in <7505e1ded68144da95fe0bd520bab178>:0
    36. 08-21 13:24:39.576: E/CRASH(23605):     #23  il 00000073  at (wrapper remoting-invoke-with-check) Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake (Mono.Net.Security.AsyncOperationStatus) <0x00073>
    37. 08-21 13:24:39.576: E/CRASH(23605):     #24  il 00000027  at Mono.Net.Security.AsyncHandshakeRequest.Run (Mono.Net.Security.AsyncOperationStatus) [0x00006] in <7505e1ded68144da95fe0bd520bab178>:0
    38. 08-21 13:24:39.576: E/CRASH(23605):     #25  il 000002b7  at Mono.Net.Security.AsyncProtocolRequest/<ProcessOperation>d__24.MoveNext () [0x000ff] in <7505e1ded68144da95fe0bd520bab178>:0
    39. 08-21 13:24:39.576: E/CRASH(23605):     #26  il 00000087  at System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner.InvokeMoveNext (object) [0x00000] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    40. 08-21 13:24:39.576: E/CRASH(23605):     #27  il 0000019f  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00071] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    41. 08-21 13:24:39.581: E/CRASH(23605):     #28  il 0000002b  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00000] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    42. 08-21 13:24:39.581: E/CRASH(23605):     #29  il 000000ab  at System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner.Run () [0x00024] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    43. 08-21 13:24:39.581: E/CRASH(23605):     #30  il 0000007b  at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction (System.Action,bool,System.Threading.Tasks.Task&) [0x0001c] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    44. 08-21 13:24:39.581: E/CRASH(23605):     #31  il 00000127  at System.Threading.Tasks.Task.FinishContinuations () [0x00068] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    45. 08-21 13:24:39.581: E/CRASH(23605):     #32  il 0000009f  at System.Threading.Tasks.Task.FinishStageThree () [0x0003c] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    46. 08-21 13:24:39.581: E/CRASH(23605):     #33  il 000000f3  at System.Threading.Tasks.Task`1<System.Nullable`1<int>>.TrySetResult (System.Nullable`1<int>) [0x0004f] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    47. 08-21 13:24:39.581: E/CRASH(23605):     #34  il 0000007f  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<System.Nullable`1<int>>.SetResult (System.Nullable`1<int>) [0x0003e] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    48. 08-21 13:24:39.581: E/CRASH(23605):     #35  il 0000043f  at Mono.Net.Security.AsyncProtocolRequest/<InnerRead>d__25.MoveNext () [0x00169] in <7505e1ded68144da95fe0bd520bab178>:0
    49. 08-21 13:24:39.581: E/CRASH(23605):     #36  il 00000087  at System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner.InvokeMoveNext (object) [0x00000] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    50. 08-21 13:24:39.581: E/CRASH(23605):     #37  il 0000019f  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00071] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    51. 08-21 13:24:39.581: E/CRASH(23605):     #38  il 0000002b  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00000] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    52. 08-21 13:24:39.581: E/CRASH(23605):     #39  il 000000ab  at System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner.Run () [0x00024] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    53. 08-21 13:24:39.581: E/CRASH(23605):     #40  il 0000007b  at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction (System.Action,bool,System.Threading.Tasks.Task&) [0x0001c] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    54. 08-21 13:24:39.581: E/CRASH(23605):     #41  il 00000127  at System.Threading.Tasks.Task.FinishContinuations () [0x00068] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    55. 08-21 13:24:39.581: E/CRASH(23605):     #42  il 0000009f  at System.Threading.Tasks.Task.FinishStageThree () [0x0003c] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    56. 08-21 13:24:39.581: E/CRASH(23605):     #43  il 000000df  at System.Threading.Tasks.Task`1<int>.TrySetResult (int) [0x0004f] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    57. 08-21 13:24:39.581: E/CRASH(23605):     #44  il 0000006f  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<int>.SetResult (int) [0x0003e] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    58. 08-21 13:24:39.581: E/CRASH(23605):     #45  il 000006f3  at Mono.Net.Security.MobileAuthenticatedStream/<InnerRead>d__66.MoveNext () [0x00181] in <7505e1ded68144da95fe0bd520bab178>:0
    59. 08-21 13:24:39.581: E/CRASH(23605):     #46  il 00000087  at System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner.InvokeMoveNext (object) [0x00000] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    60. 08-21 13:24:39.581: E/CRASH(23605):     #47  il 0000019f  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00071] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    61. 08-21 13:24:39.581: E/CRASH(23605):     #48  il 0000002b  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00000] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    62. 08-21 13:24:39.581: E/CRASH(23605):     #49  il 000000ab  at System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner.Run () [0x00024] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    63. 08-21 13:24:39.581: E/CRASH(23605):     #50  il 0000007b  at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction (System.Action,bool,System.Threading.Tasks.Task&) [0x0001c] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    64. 08-21 13:24:39.581: E/CRASH(23605):     #51  il 00000127  at System.Threading.Tasks.Task.FinishContinuations () [0x00068] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    65. 08-21 13:24:39.581: E/CRASH(23605):     #52  il 0000009f  at System.Threading.Tasks.Task.FinishStageThree () [0x0003c] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    66. 08-21 13:24:39.581: E/CRASH(23605):     #53  il 00000173  at System.Threading.Tasks.Task.FinishStageTwo () [0x000d4] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    67. 08-21 13:24:39.581: E/CRASH(23605):     #54  il 000000cf  at System.Threading.Tasks.Task.Finish (bool) [0x00036] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    68. 08-21 13:24:39.581: E/CRASH(23605):     #55  il 0000014f  at System.Threading.Tasks.Task.ExecuteWithThreadLocal (System.Threading.Tasks.Task&) [0x00067] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    69. 08-21 13:24:39.581: E/CRASH(23605):     #56  il 000000ef  at System.Threading.Tasks.Task.ExecuteEntry (bool) [0x00058] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    70. 08-21 13:24:39.581: E/CRASH(23605):     #57  il 00000017  at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00000] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    71. 08-21 13:24:39.586: E/CRASH(23605):     #58  il 00000217  at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    72. 08-21 13:24:39.586: E/CRASH(23605):     #59  il 00000037  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <dd5ad072bbb44eaa9c17089b0641164a>:0
    73. 08-21 13:24:39.586: E/CRASH(23605):     #60  il 0000006f  at (wrapper runtime-invoke) <Module>.runtime_invoke_bool (object,intptr,intptr,intptr) <0x0006f>
    74.  
     
  42. cryptoforge

    cryptoforge

    Joined:
    Jan 21, 2015
    Posts:
    60
    @andreasreich I already moved on from this issue. The problem does not happen when I use self-signed certificates. Only happens with Let’s Encrypt ones which is weird. My game unfortunately has another problem where during switching to .Net4.0, Unity crashes. For the sake of moving on, I am rolling with self-signed ones for now until further need. Hope new bit of info helps.
     
  43. andreasreich

    andreasreich

    Unity Technologies

    Joined:
    Sep 24, 2017
    Posts:
    55
    @EduardMatveev Thanks for reporting this issue! Something's clearly amiss on our side here, there should never be a a crash in native with all of this. Can you please create a bug with a repro case (if possible) so I can look into it? Thank you!
     
  44. andreasreich

    andreasreich

    Unity Technologies

    Joined:
    Sep 24, 2017
    Posts:
    55
    @playent I hope you reported the .Net4 switching crash already :). We're trying to make .Net4 the new default asap and for a proper judgement on when we're ready for it we need all the reports we can get.

    Outside of .Net4 we don't provide any guarantees on TLS support. Some things work, some don't. You get whatever "old mono" had in store for it and we never tested it thoroughly.
     
  45. EduardMatveev

    EduardMatveev

    Joined:
    Mar 10, 2015
    Posts:
    2
    andreasreich likes this.
  46. andreasreich

    andreasreich

    Unity Technologies

    Joined:
    Sep 24, 2017
    Posts:
    55
    Thanks, I'll look at it asap!
     
  47. AlleywayDave

    AlleywayDave

    Joined:
    Jan 12, 2014
    Posts:
    13
    @andreasreich I'm excited that I'm now able to connect and exchange data with SslStream using TLS 1.2, using version 2018.2.6f1 on Windows. However, I found an odd issue that others may not encounter. When the other end of an SslStream shuts down (orderly or not), ReadAsync never completes its operation and the task runs indefinitely. It should instead complete its Task<int> and reading Result should return 0. In regular Mono 5.x SslStream does not seem to exhibit this problem (Windows, Linux). I have tried working around this to no avail. It is probably trivial to test, but I can put together a project and submit a bug report if you'd like.

    I noticed this when doing my initial tests. Needing a simple TLS 1.2 server, I just used my web server and performed an HTTP/1.0 request. The server is expected to shut down the SSL connection in this case, and I was able to verify that the server did a shutdown and closed the socket. SslStream reads the response, but never handles the shutdown, and the underlying socket shows data available. Since there is no way to check what the underlying socket is receiving without disrupting the stream, and because a read is required on the socket to determine it's closed, there is no reasonable workaround that I can find.

    Thanks!
     
    Cromfeli likes this.
  48. andreasreich

    andreasreich

    Unity Technologies

    Joined:
    Sep 24, 2017
    Posts:
    55
    @AlleywayDave thanks for very much for the feedback! Somebody else already reported this bug, it is going to be fixed in 2018.2.7 (missed 2018.2.6 just by a bit :()
    Would be great if you could confirm the fix once it is out, just in case
     
  49. andreasreich

    andreasreich

    Unity Technologies

    Joined:
    Sep 24, 2017
    Posts:
    55
    Actually I did have a lot of trouble creating a minimal repro case that would hit the bug reliably (in the report it happened randomly). You sound like you were able to get it reliably, I'd really like to have this as a regression test in Unity. If it is no trouble for you, could you give me code/a project to that?
     
    Cromfeli likes this.
  50. AlleywayDave

    AlleywayDave

    Joined:
    Jan 12, 2014
    Posts:
    13
    @andreasreich Yes, I've put one together, but I will make a few improvements to the code and submit it.