'"System.ComponentModel.Win32Exception (0x80090308): The token supplied to the function is invalid" when TLS13 is enabled
After adding the below registry key to enable TLS1.3 on Windows Server 2022
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Client]
"DisabledByDefault"=dword:00000000
"Enabled"=dword:00000001
The .NET Client application throws the below exception
System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception.
---> System.ComponentModel.Win32Exception (0x80090308): The token supplied to the function is invalid
--- End of inner exception stack trace ---
at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm)
at System.Net.Security.SslStream.AuthenticateAsClient(SslClientAuthenticationOptions sslClientAuthenticationOptions)
at System.Net.Security.SslStream.AuthenticateAsClient(String targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation)
Is there anything i am missing? In the .NET Client application i had set the protocol version to TLS13.
Thanks in advance.
Solution 1:[1]
Try the below before you call the server if server is also on windows 2022+
Otherwise it will not work if server is not 2022+
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls13
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Alander |