Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command "git credential-manager-core diagnose" fails Networking diagnostic when used with NTLM proxy #927

Closed
cjquintero opened this issue Oct 27, 2022 · 0 comments · Fixed by #942
Labels
bug A bug in Git Credential Manager network Related to networking (VPN, TCP/IP, etc) platform:windows Specific to the Windows platform

Comments

@cjquintero
Copy link

cjquintero commented Oct 27, 2022

Which version of GCM are you using?

From a terminal, run git credential-manager-core --version and paste the output.

2.0.785+6074e4e3d3

Problem description

I am on a Windows 10 corporate computer behind a proxy that uses NTLM authentication.

My .gitconfig file has a configuration like this, that is, with empty credentials:

[http]
	proxy = http://:@myproxy.mycompany.com:80

Commands such as the following work as expected showing the browser window to authenticate:

git clone https://[email protected]/myorg/myteamproject/_git/myrepo

So far so good. That works (as expected) because credential-manager-core, when gitconfig has empty credentials internally creates an instance of WebProxy with UseDefaultCredentials = true. See:

https://github.com/GitCredentialManager/git-credential-manager/blob/main/src/shared/Core/HttpClientFactory.cs#L240-L243

However, when I run this command:

git credential-manager-core diagnose

Expected behavior

No exception, all (seven) diagnostics should pass.

Actual behavior

The Networking diagnostic fails because it requests proxy authentication (message translated to English):

[FAIL] Networking

    [!] Encountered an exception [!]
    System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The remote server returned an error: (407) Proxy Authentication Required.

Root cause

The root cause is that the Networking diagnostic creates a rawHttpClient = new HttpClient() without proxy, whose call fails and returns:

https://github.com/GitCredentialManager/git-credential-manager/blob/main/src/shared/Core/Diagnostics/NetworkingDiagnostic.cs#L30-L33

and there is another bug a few lines later: the contextHttpClient = _httpFactory.CreateClient(), who is created with proxy and that would succeed, is never used, the code of the call uses rawHttpClient again:

https://github.com/GitCredentialManager/git-credential-manager/blob/main/src/shared/Core/Diagnostics/NetworkingDiagnostic.cs#L37-L40

@cjquintero cjquintero added the auth-issue An issue authenticating to a host label Oct 27, 2022
@mjcheetham mjcheetham added platform:windows Specific to the Windows platform network Related to networking (VPN, TCP/IP, etc) bug A bug in Git Credential Manager and removed auth-issue An issue authenticating to a host labels Nov 3, 2022
ldennington added a commit that referenced this issue Nov 3, 2022
The Network diagnostic currently makes two passes of the tests, one
using a 'raw' `HttpClient` and another using one created by the product
`HttpClientFactory`.

However, we've not actually been using the factory-built client in the
tests! Furthermore, the raw HTTP client will not exercise test correctly
if the machine is behind a corporate proxy, so let's just drop that
option.

Fixes #927
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug in Git Credential Manager network Related to networking (VPN, TCP/IP, etc) platform:windows Specific to the Windows platform
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants