Visual Studio 2019 update breaks publishing (incorrect TLS version)

Viewed 270

Short version:

How to change the default TLS version of Visual Studio 2019 used to fetch dependencies?

Long version:

As of Visual Studio 2019 v16.7.1 (the latest v16.7.2 doesn't fix this) I seem unable to publish any dotnet core project. The publishing operation always crashes with the following message:

Publish has encountered an error.
Publish has encountered an error. We were unable to determine the cause of the error.
Check the output log for more details.

Taking a look at the output window: error message

As can be seen VS seems to fail trying to establish a TLS connection to nuget. Further investigation using Wireshark for monitoring while publishing reveals this:

wireshark failing

As can be clearly seen the connection fails due to an incorrect TLS version. Visual Studio seems to use TLSv1 which isn't supported by the nuget api. We can also see that VS is retrying a couple of times thus the large amount of packets.

Manually connecting to https://api.nuget.org/v3/index.json using my web browser shows that nuget.org actually uses TLSv1.2:

wireshark success

So my question is: How do I tell Visual Studio to use TLSv1.2 instead of TLSv1 to connect to nuget.org? Or is it possible at all? Is there a Windows registry key for this?

I haven't tried reinstalling VS yet but if possible I'd like to avoid doing so.

1 Answers

As was pointed out in the comments setting the following registry keys:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp\
      DefaultSecureProtocols = (DWORD): 0xAA0
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp\
      DefaultSecureProtocols = (DWORD): 0xAA0

(more documentation here and here) in combination with un-checking the Use TLS 1.0 option under Internet Options -> Advanced in the Windows 7 control panel did the trick.

Related