Force.com-Toolkit-for-NET icon indicating copy to clipboard operation
Force.com-Toolkit-for-NET copied to clipboard

Force TLS version to at least 1.1

Open pozil opened this issue 8 years ago • 9 comments

By default .NET uses TLS 1.0 but since Summer 16, connections are only allowed with TLS 1.1 or above.

When testing the console sample app, connections using TLS 1.0 will be rejected with a really unclear error message: "retry your request".

Please add a test to prevent the connection being established with an insufficient TLS version or force a default version.

pozil avatar Aug 09 '16 18:08 pozil

To be clear, .NET < 4.6 uses TLS 1.0, you should be set if you use >= 4.6. I do not, and needed a very quick (non-portable) solution to the problem, maybe it can help you out for the time being? If not no worries, this should really be fixed in the main repo though.

(edit: wrong .NET version)

jcalabro avatar Aug 19 '16 15:08 jcalabro

@jcalabro Why fork and not submit a pull request with fixes for others to use?

wadewegner avatar Aug 19 '16 15:08 wadewegner

@pozil That's a good suggestion.

wadewegner avatar Aug 19 '16 15:08 wadewegner

I ruined the portability of it, and I don't currently have the time to make a portable solution unfortunately :/

jcalabro avatar Aug 19 '16 15:08 jcalabro

@jcalabro Understood. If you'll point out the significant updates I'd be happy to take them into consideration and update if possible (while keeping it portable).

wadewegner avatar Aug 19 '16 15:08 wadewegner

Certainly. Qucik note, I renamed the projects and removed the ones I didn't need in the fork to avoid confusion about which .dll I'd be referencing in my projects in the future, sorry if that throws you off.

This was a very helpful SO post that got me pointed in the right direction (I spent a while trying to debug this issue before hand).

The only code I changed was a single line addition in CommonLibrariesForNETNonPortable/AuthenticationClient.cs on line 34, on which I simply inserted

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

I simply haven't done enough research to know whether or not there's a cross-platform implementation of TLS >1.0; I've never written for any .NET platform other than the .NET framework :). A quick google search doesn't bring much up unfortunately, but I bet you know better than I do.

jcalabro avatar Aug 19 '16 15:08 jcalabro

Unfortunately, I ended up working on a legacy .NET version (2.0) so I had to give up using this integration project.

However before realizing that the .NET version would be an issue I came to the same conclusion as @jcalabro.

pozil avatar Aug 19 '16 15:08 pozil

Found the same solution as @jcalabro, except I placed it in the Global.asax for the Web App. I wasn't able to insert it into the PCL since it was missing a reference and I wanted a solution that I could use with the Nuget libraries right away.

richhosek avatar Sep 07 '16 20:09 richhosek

I have created a pull request (#231) which addresses this issue as well as a couple others I ran into getting this project running.

migasj avatar Nov 21 '16 22:11 migasj