-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Milestone
Description
Description
I need to connect to a server via TcpClient and SslStream which requires TLS >= 1.2. The server can be configured to require a valid client certificate (TLS mutual authentication).
My scenario: Server is configured to require a client certificate but my client calls SslStream.AuthenticateAsClientAsync without any client certificates.
Client environment:
- Windows (>= v10)
- .NET 6
Reproduction Steps
None
Expected behavior
The method AuthenticateAsClientAsync throws an AuthenticationException because the server requires a valid client certificate, but none is provided.
This works as expected on Win10 20H2 with TLS 1.2.
- Note: This Windows version does not support TLS 1.3 and because of that TLS 1.2 is used.
Actual behavior
- Environment: Win11 21H2 with TLS 1.3
- The
AuthenticateAsClientAsyncmethod returns successfully and theSslStream.IsAuthenticatedproperty returns true.- WRONG BEHAVIOR as the authentication could not be successfully without providing the client certificates.
- However, when the
SslStreamis used the following exception is thrown:
System.IO.IOException
HResult=0x80131620
Message=The decryption operation failed, see inner exception.
Source=System.Net.Security
StackTrace:
at System.Net.Security.SslStream.<ReadAsyncInternal>d__186`1.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
...
Inner Exception 1:
Win32Exception: The message received was unexpected or badly formatted.
Regression?
TLS 1.2: Correct behavior
TLS 1.3: Wrong behavior
Known Workarounds
No response
Configuration
No response
Other information
No response
dif-sam