-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Open
Labels
area-System.Net.Securitytracking-external-issueThe issue is caused by external problem (e.g. OS) - nothing we can do to fix it directlyThe issue is caused by external problem (e.g. OS) - nothing we can do to fix it directly
Milestone
Description
Description
Hello,
we have encountered a weird behaviour where if we create a HttpClient and first send a request (e.g. using HttpClient.GetAsync) to https://<redacted>.com and then to https://<redacted>.com:8000, we get a System.ComponentModel.Win32Exception (0x80090304): The Local Security Authority cannot be contacted. But if we do it the other way around, i.e. sending the request first to :8000 and then to uri without port (i.e. :443), it works just fine.
Is this an expected behaviour?
Reproduction Steps
// The FQDN is the same in all cases
// Does not work (throws exception)
/*
* Unhandled exception. System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner 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](Boolean receiveFirst, Byte[] reAuthenticationData, CancellationToken cancellationToken)
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(QueueItem queueItem)
at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.WaitWithCancellationAsync(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) in C:\workspace\work\temp\ConsoleApp3\ConsoleApp3\Program.cs:line 5
*/
var firstHttpClient = new HttpClient();
await firstHttpClient.GetAsync("https://<redacted>.com");
await firstHttpClient.GetAsync("https://<redacted>.com:8000"); // <- this call throws the exception above
// Works (no exception)
var secondHttpClient = new HttpClient();
await secondHttpClient.GetAsync("https://<redacted>.com:8000");
await secondHttpClient.GetAsync("https://<redacted>.com");Expected behavior
No exception is thrown and it doesn't depend in which order we send requests.
Actual behavior
An exception is thrown (see reproduction steps).
Regression?
No response
Known Workarounds
The workaround for us is to use separate HttpClient instances.
Configuration
net8 running on x64 Windows 11.
Other information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-System.Net.Securitytracking-external-issueThe issue is caused by external problem (e.g. OS) - nothing we can do to fix it directlyThe issue is caused by external problem (e.g. OS) - nothing we can do to fix it directly