Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requiring TLS 1.3 results in LSA error on Windows 10 21H1 for SslStream #53537

Closed
vcsjones opened this issue Jun 1, 2021 · 13 comments
Closed

Comments

@vcsjones
Copy link
Member

vcsjones commented Jun 1, 2021

Description

Steps to reproduce:

It seems that if I explicitly use SslProtocols.Tls13 when authenticating as a client, I get "Win32Exception (0x80090304): The Local Security Authority cannot be contacted". If I do not explicitly set the SslProtocols, it will successfully negotiate TLSv1.3.

  1. Enable TLSv1.3 on Windows 10 21H1 (Build 19043.985), reboot.

    I did this with:

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Client]
    "DisabledByDefault"=dword:00000000
    "Enabled"=dword:00000001
    
  2. Run the following snippet:

    using System;
    using System.Net.Security;
    using System.Net.Sockets;
    using System.Security.Authentication;
    
    using TcpClient client = new TcpClient();
    await client.ConnectAsync("github.com", 443);
    
    await using SslStream sslStream = new SslStream(client.GetStream());
    await sslStream.AuthenticateAsClientAsync("github.com", null, SslProtocols.Tls13, true);
    Console.WriteLine(sslStream.SslProtocol);

It will fail for me with:

Unhandled exception. System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception.
 ---> System.ComponentModel.Win32Exception (0x80090304): The Local Security Authority cannot be contacted
   --- End of inner exception stack trace ---
   at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm)
   at <Program>$.<<Main>$>d__0.MoveNext() in D:\code\personal\scratch\Program.cs:line 10
--- End of stack trace from previous location ---
   at <Program>$.<<Main>$>d__0.MoveNext() in D:\code\personal\scratch\Program.cs:line 11
--- End of stack trace from previous location ---
   at <Program>$.<Main>(String[] args)

If I change AuthenticateAsClientAsync to await sslStream.AuthenticateAsClientAsync("github.com"); by removing the explicit protocol configuration, it does not fail and correctly negotiates TLSv1.3.

Configuration

Reproduces on .NET 5 and .NET 6 Preview 4.

@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Net.Security untriaged New issue has not been triaged by the area owner labels Jun 1, 2021
@ghost
Copy link

ghost commented Jun 1, 2021

Tagging subscribers to this area: @dotnet/ncl, @vcsjones
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

Steps to reproduce:

It seems that if I explicitly use SslProtocols.Tls13 when authenticating as a client, I get "Win32Exception (0x80090304): The Local Security Authority cannot be contacted". If I do not explicitly set the SslProtocols, it will successfully negotiate TLSv1.3.

  1. Enable TLSv1.3 on Windows 10 21H1 (Build 19043.985), reboot.

    I did this with:

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Client]
    "DisabledByDefault"=dword:00000000
    "Enabled"=dword:00000001
    
  2. Run the following snippet:

    using System;
    using System.Net.Security;
    using System.Net.Sockets;
    using System.Security.Authentication;
    
    using TcpClient client = new TcpClient();
    await client.ConnectAsync("github.com", 443);
    
    await using SslStream sslStream = new SslStream(client.GetStream());
    await sslStream.AuthenticateAsClientAsync("github.com", null, SslProtocols.Tls13, true);
    Console.WriteLine(sslStream.SslProtocol);

It will fail for me with:

Unhandled exception. System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception.
 ---> System.ComponentModel.Win32Exception (0x80090304): The Local Security Authority cannot be contacted
   --- End of inner exception stack trace ---
   at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm)
   at <Program>$.<<Main>$>d__0.MoveNext() in D:\code\personal\scratch\Program.cs:line 10
--- End of stack trace from previous location ---
   at <Program>$.<<Main>$>d__0.MoveNext() in D:\code\personal\scratch\Program.cs:line 11
--- End of stack trace from previous location ---
   at <Program>$.<Main>(String[] args)

If I change AuthenticateAsClientAsync to await sslStream.AuthenticateAsClientAsync("github.com"); by removing the explicit protocol configuration, it does not fail and correctly negotiates TLSv1.3.

Configuration

Reproduces on .NET 5 and .NET 6 Preview 4.

Author: vcsjones
Assignees: -
Labels:

area-System.Net.Security, untriaged

Milestone: -

@karelz
Copy link
Member

karelz commented Jun 3, 2021

Triage: Likely problem in the OS. We should confirm and send it over.

@wfurt
Copy link
Member

wfurt commented Jun 3, 2021

can you try it on Server2022+ @vcsjones ? I took it to Schannel team and I was told that 21H1 is unsupported platform.

@vcsjones
Copy link
Member Author

vcsjones commented Jun 3, 2021

I was told that 21H1 is unsupported platform.

Ah. Hmm. I apparently had the wrong impression on that. I thought it was "supported but off by default". Will try and report back.

@wfurt
Copy link
Member

wfurt commented Jun 3, 2021

I'm trying to clarify. It seems like 21H1 is missing from the table here https://docs.microsoft.com/en-us/windows/win32/secauthn/protocols-in-tls-ssl--schannel-ssp-

@vcsjones
Copy link
Member Author

vcsjones commented Jun 3, 2021

@wfurt Ohhh. I looked at this doc a long time ago and it used to say 21H1, which is probably why I was given that impression.

It appears to have changed a few months ago. MicrosoftDocs/win32@45fe995#diff-93e62a5793d2a9571e3d97b3d5452653a0d6d9385e1bcee53c28d5cf369206c7

@wfurt
Copy link
Member

wfurt commented Jun 3, 2021

Thanks. I'm trying to clarify as well. Do you have repro to particular server or is that pretty consistent? I saw something similar while back running .NET test suite so I'll try to collect more insight.

@vcsjones
Copy link
Member Author

vcsjones commented Jun 3, 2021

Do you have repro to particular server

github.com seems to do it. vcsjones.dev will as well.

@karelz
Copy link
Member

karelz commented Jun 8, 2021

@wfurt what is the next step here?

@wfurt
Copy link
Member

wfurt commented Jun 8, 2021

Can you get Schannel traces @vcsjones and/or try in on 22 server? I see something similar on supported os but for me it is somewhat rare and non-deterministic.

@vcsjones
Copy link
Member Author

vcsjones commented Jun 8, 2021

@wfurt will do; might take me a day or two to find the time. Sorry and thanks y'all for the patience!

@wfurt
Copy link
Member

wfurt commented Jun 9, 2021

That is ok. There is some interest from Schannel team and it may help them to improve the product.

@vcsjones
Copy link
Member Author

I can't get it to reproduce on Windows Server 2022 Preview. I'll close this then and if I find anything that does reproduce on Windows Server 2022 I will re-open or raise a new issue.

@karelz karelz added this to the 6.0.0 milestone Jul 15, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Aug 14, 2021
@karelz karelz removed the untriaged New issue has not been triaged by the area owner label Oct 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants