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

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!

1 Like

Thank you, really nice to hear that :slight_smile:

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)

1 Like

Any update on this progress or any issues popping up for limitations or everything good for 2018.2?

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.

Well it works with 2018.2b10, in the QA test I sent in, but not in my project. So bizarre.

I got it, it works. yay! Will do a wireshark test later, but the protocols are set to Tls12 so that’s good!

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.

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%.

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 :slight_smile:

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.

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.

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 :slight_smile:

3 Likes

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:

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

public void SendEmail(string email, string password, Action<Error> callback = null) {
        _emailSentCallback = callback;

        _mailMessage = new MailMessage {
            From = new MailAddress(_fromEmail),
            Subject = "subject",
            Body = "body"
        };

        _mailMessage.To.Add(email);

        SmtpClient smtpServer = new SmtpClient("smtp.office365.com") {
            Port = 587,
            EnableSsl = true,
            UseDefaultCredentials = false,
            DeliveryMethod = SmtpDeliveryMethod.Network,
            Credentials = new System.Net.NetworkCredential(_username, _password) as ICredentialsByHost
        };

        ServicePointManager.ServerCertificateValidationCallback = delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
      
        smtpServer.SendCompleted += new SendCompletedEventHandler(EmailSentCallback);
        smtpServer.SendAsync(_mailMessage, _uniqueToken);
    }

I’ve also tried adding this line before calling the function with no sucess.

Any idea what it might be?
Cheers.

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?

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.

Thanks, we’ll investigate this.

1 Like

Got a reply with a alpha build to test it out and it works. :slight_smile:
Awesome response time from the Unity team.

The fix will be released with Unity 2017.3.0.

I think you would say 2018.3 but great to hear that !

Can’t establish a secure websocket connection using websockets-sharp because Tls 1.2 support is non existent on Unity macos. Total BS… $&%#!

1 Like

@cryptoforge Can you please elaborate? What errors are you getting exactly? TLS1.2 should work in 2018.2 with .Net4