Skip to content

HttpClient throws exception when using invalid username/password on Linux #416

Description

@davidsh

Found during my enterprise-scenario testing.

Sending a request with HttpClient to a server that requires Negotiate scheme authentication throws an exception on Linux when an incorrect username/password is used.

Sample repro:

[Fact]publicasyncTaskHttpClient_InvalidAuthentication_Failure(){usingvarhandler=newHttpClientHandler();handler.Credentials=TestConfiguration.InvalidNetworkCredentials;usingvarclient=newHttpClient(handler);usingHttpResponseMessageresponse=awaitclient.GetAsync(TestConfiguration.NegotiateAuthWebServer);Assert.Equal(HttpStatusCode.Unauthorized,response.StatusCode);}

Stack:

System.Net.Http.Enterprise.Tests.HttpClientEnterpriseTest.HttpClient_InvalidAuthentication_Failure [FAIL]
System.ComponentModel.Win32Exception : GSSAPI operation failed with error - Unspecified GSS failure. Minor code may provide more information (SPNEGO failed to negotiate a mechanism).
Stack Trace:
/repo/src/libraries/Common/src/System/Net/NTAuthentication.Common.cs(285,0): at System.Net.NTAuthentication.GetOutgoingBlob(Byte[] incomingBlob, Boolean throwOnError, SecurityStatusPal& statusCode) /repo/src/libraries/Common/src/System/Net/NTAuthentication.Common.cs(187,0): at System.Net.NTAuthentication.GetOutgoingBlob(String incomingBlob)

On Windows, an invalid username/password will simply cause no auth token to be generated and a final HTTP status code 401 will result for the request.

Metadata

Metadata

Assignees

Labels

area-System.Net.Httpbugdisabled-testThe test is disabled in source code against the issueos-linuxLinux OS (any supported distro)tenet-compatibilityIncompatibility with previous versions or .NET Framework

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions