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]
public async Task HttpClient_InvalidAuthentication_Failure()
{
    using var handler = new HttpClientHandler();
    handler.Credentials = TestConfiguration.InvalidNetworkCredentials;
    using var client = new HttpClient(handler);

    using HttpResponseMessage response = await client.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.

Activity

  1. added this to the 5.0 milestone on Dec 1, 2019
  2. self-assigned this
    on Dec 1, 2019
  3. removed
    untriagedNew issue has not been triaged by the area owner
    on Dec 1, 2019
  4. added
    disabled-testThe test is disabled in source code against the issue
    on Feb 20, 2020
  5. removed their assignment
    on Jun 26, 2020
  6. self-assigned this
    on Jul 9, 2020
  7. modified the milestones: 5.0.0, 6.0.0 on Aug 10, 2020
  8. added
    tenet-compatibilityIncompatibility with previous versions or .NET Framework
    disabled-testThe test is disabled in source code against the issue
    and removed
    disabled-testThe test is disabled in source code against the issue
    on Aug 10, 2020
  9. added a commit that references this issue on Mar 25, 2021
    4f617ff
  10. modified the milestones: 6.0.0, Future on May 4, 2021
  11. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Jun 13, 2022
  12. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Jun 14, 2022
  13. ghost locked as resolved and limited conversation to collaborators on Jul 14, 2022
  14. modified the milestones: Future, 7.0.0 on Jul 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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