Skip to content

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

Closed

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
    os-linux
    on Dec 1, 2019
  2. added this to the 5.0 milestone on Dec 1, 2019
  3. self-assigned this
    on Dec 1, 2019
  4. added
    untriaged
    on Dec 1, 2019
  5. removed
    untriaged
    on Dec 1, 2019
  6. added
    disabled-test
    on Feb 20, 2020
  7. removed their assignment
    on Jun 26, 2020
  8. self-assigned this
    on Jul 9, 2020
  9. modified the milestones: 5.0.0, 6.0.0 on Aug 10, 2020
  10. added
    tenet-compatibility
    disabled-test
    and removed
    disabled-test
    on Aug 10, 2020
  11. added a commit that references this issue on Mar 25, 2021
    4f617ff
  12. modified the milestones: 6.0.0, Future on May 4, 2021
  13. ghost added
    in-pr
    on Jun 13, 2022
  14. ghost removed
    in-pr
    on Jun 14, 2022
  15. ghost locked as resolved and limited conversation to collaborators on Jul 14, 2022
  16. 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-testos-linuxtenet-compatibility

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions