braintree / braintree_dotnet

Braintree .NET library
https://developer.paypal.com/braintree/docs/start/overview
MIT License
136 stars 73 forks source link

Mono support with TLS 1.2 #54

Closed george-vlahakis closed 7 years ago

george-vlahakis commented 7 years ago

Seems that there is no support for TLS 1.2 with current implementation in Mono. At least not at the server side (ASPX).

Calling gateway.ClientToken.generate() generates:

Mono.Security.Protocol.Tls.TlsException The authentication or decryption has failed. Description: HTTP 500.Error processing request. Details: Non-web exception. Exception origin (name of application or object): Mono.Security. Exception stack trace: at Mono.Security.Protocol.Tls.RecordProtocol.EndReceiveRecord (System.IAsyncResult asyncResult) [0x0003a] in /private/tmp/source-mono-4.8.0/bockbuild-mono-4.8.0-branch/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/RecordProtocol.cs:430 at Mono.Security.Protocol.Tls.SslClientStream.SafeEndReceiveRecord (System.IAsyncResult ar, System.Boolean ignoreEmpty) [0x00000] in /private/tmp/source-mono-4.8.0/bockbuild-mono-4.8.0-branch/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SslClientStream.cs:256 at Mono.Security.Protocol.Tls.SslClientStream.NegotiateAsyncWorker (System.IAsyncResult result) [0x00071] in /private/tmp/source-mono-4.8.0/bockbuild-mono-4.8.0-branch/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SslClientStream.cs:418 Version Information: 4.8.0 (mono-4.8.0-branch/e4a3cf3 Fri Feb 17 15:57:45 EST 2017); ASP.NET Version: 4.0.30319.42000

george-vlahakis commented 7 years ago

Some progress:

If I run the XSP server from the command line with MONO_TLS_PROVIDER=btls it seems to work. So doing the following before calling the generate() function works!

System.Environment.SetEnvironmentVariable("MONO_TLS_PROVIDER", "btls");

This is for Mono 4.8 (obviously)

bluk commented 7 years ago

Awesome. Great that you figured it out!

I'll close this issue since it seems resolved.