runtime: Got Win32Exception when I send an HTTPS request
Description
I get Win32Exception error (0x80090326) when I send HTTPS requests.
Reproduction Steps
Two lines of code are enough to reproduce
var client = new HttpClient();
var response = await client.GetAsync("https://google.com/");
Expected behavior
It is expected that I will receive the contents of the page google.com in response
Actual behavior
Actually I get the error below
Unhandled exception. System.Net.Http.HttpRequestException: An error occurred while sending the request.
---> System.IO.IOException: The read operation failed, see inner exception.
---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception.
---> System.ComponentModel.Win32Exception (0x80090326): The message received was unexpected or badly formatted.
--- End of inner exception stack trace ---
at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](Boolean receiveFirst, Byte[] reAuthenticationData, CancellationToken cancellationToken)
at System.Net.Security.SslStream.ReplyOnReAuthenticationAsync[TIOAdapter](Byte[] buffer, CancellationToken cancellationToken)
at System.Net.Security.SslStream.ReadAsyncInternal[TIOAdapter](Memory`1 buffer, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Security.SslStream.ReadAsyncInternal[TIOAdapter](Memory`1 buffer, CancellationToken cancellationToken)
at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
at System.Net.Http.HttpConnection.InitialFillAsync(Boolean async)
at System.Net.Http.HttpConnection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.HttpConnection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
at Program.<Main>$(String[] args)
Regression?
This applies equally to httpclient, WebClient, HttpWebRequest. This applies equally to all versions .NET Core, from 2.1 to 8.0. This also applies to .NET Framework 4.8.1. This is reproduced in both Windows 22h2 and Debian 12 located on my local network. This is not fixed with a VPN.
This is not reproducible in the browser (using JS) and is not reproducible using Python
Known Workarounds
No response
Configuration
I use .NET 8.0, but its applies to all other .NETs. I use Windows 10 22h2, but its also applies to Debian 12. I use x64 architecture
Other information
No response
About this issue
- Original URL
- State: closed
- Created 10 months ago
- Comments: 27 (15 by maintainers)
I fixed it! https://stackoverflow.com/questions/56072561/how-to-enable-tls-1-3-in-windows-10/59210166#59210166
But on the contrary, it was necessary to turn off
"Enabled"=dword:00000000
Thank you!
My mistake. Here is the correct HTTPS TLS 1.2 capture
https://1dndn.ru/files/google2.zip
TLS 1.2 working properly
Console output:
CODE-OF-CONDUCT.md