microsoft / Git-Credential-Manager-for-Windows

Secure Git credential storage for Windows with support for Visual Studio Team Services, GitHub, and Bitbucket multi-factor authentication.
Other
2.86k stars 591 forks source link

Installation Error - An error occured when updating the local system #670

Open nbstrat opened 6 years ago

nbstrat commented 6 years ago

While updating my versions of Git and Git Credentials Manager for Windows in an attempt to correct the "HttpRequestException encountered. An error occurred while sending the request." messages, I get the following message when installing Git Credentials Manager for Windows.

Microsoft Git Credential Manager for Windows Fatal: An error occured when updating the local system.

I of course continue to receive the "fatal: HttpRequestException encountered. An error occurred while sending the request." message on every push/pull to GitHub.

I am using git version 2.18.0.windows.1 and Git Credentials Manager for Windows version 1.16.2 on a Windows 10 workstation at my work location.
From all indications, it installed successfully as it does show up in windows control panel > installed programs, there are registry entries for the installation, and the files are located in my c:\Users\\AppDatea\Local\Programs\Microsoft Git Credential Manager for Windows directory.

I have installed this successfully on other machines without any problems and this seems to be isolated to this specific machine/installation and I am unable to fine any exceptions in the event viewer or logs that would assist me in determining the specific problem.

whoisj commented 6 years ago

@nbstrat let's try this.

  1. Open "Add or remove programs" from Windows "Settings" app.
  2. Locate the Git Credential Manager and click "Uninstall".

This should remove the bulk of the GCM, however there may be bits left behind that we want to expunge.

  1. Open Windows Explorer
  2. Remove any GCM files from %UserProfile%\bin that may exist.
  3. Remove %localappdata%\GitCredentialManager.

Now download and install the version of the GCM you want to have installed.

nbstrat commented 6 years ago

GCM would not uninstall from the Settings interface - I was presented with the standard prompts asking if I am sure that I wanted to uninstall, but the program remained in the Settings interface and the related files in my UserProfile remained.

As an alternative, I performed the following: I manually removed all registry keys related to "Microsoft Git Credential Manager for Windows". I did not have a %UserProfile%\bin directory. I removed the C:\Users\\AppData\Local\Programs\Microsoft Git Credential Manager for Windows\ folder.

Attempted installation again and got the same error prompt. Runtime Error (at 111:239): Fatal: An error occured when updating the local system.

The files previously deleted in in \AppData\Local\Programs\Microsoft Git Credential Manager for Windows\ were installed and the program again shows up in the Setting interface. I still get prompted for credentials on each push/pull to GitHub.

whoisj commented 6 years ago

@nbstrat from the a console try the following...

  1. Run git config --list --show-origin

Do you see a credential.helper=manager entry? Do you see any other credential.helper entries?

nbstrat commented 6 years ago

There are two credential.helper=manager entries.

1) file:C:/Users/nbstrat/.gitconfig 2) file:C:/Program Files/Git/mingw64/etc/gitconfig

whoisj commented 6 years ago

Ok, so that means the GCM ought to be being invoked. Let's see if it is:

  1. Open Command Prompt
  2. Run SET GIT_TRACE=1
  3. Run SET GCM_TRACE=1
  4. Run git fetch --all

Then please share the output generated, of course please redact any secret, private, or personally identifiable information before sharing.

nbstrat commented 6 years ago
$ GIT_TRACE=1

$ GCM_TRACE=1

$ git fetch --all
Fetching origin
14:18:18.720250 ...\Common.cs:665       trace: [Main] git-credential-manager (v1.16.2) 'get'
14:18:18.773674 ...\Git\Where.cs:343    trace: [FindGitInstallations] found 1 Git installation(s).
14:18:18.773674 ...Configuration.cs:222 trace: [LoadGitConfiguration] git All config read, 72 entries.
14:18:18.773674 ...\Common.cs:471       trace: [LoadOperationArguments] writeLog = 'True'.
14:18:18.773674 ...\Common.cs:284       trace: [EnableTraceLogging] trace logging enabled.
14:18:18.789291 ...\Common.cs:289       trace: [EnableTraceLogging] git local config found at 'C:\Users\ME\Documents\.git\config'.
14:18:18.789291 ...\Common.cs:344       trace: [EnableTraceLoggingFile] trace log destination is 'C:\Users\ME\Documents\.git'.
14:18:18.804920 ...\Common.cs:84        trace: [CreateAuthentication] detecting authority type for 'https://github.com/'.
14:18:18.820540 ...uthentication.cs:151 trace: [GetAuthentication] created GitHub authentication for 'https://github.com/'.
14:18:18.820540 ...\Common.cs:161       trace: [CreateAuthentication] authority for 'https://github.com/' is GitHub.
14:18:19.042670 ...icationPrompts.cs:59 trace: [CredentialModalPrompt] prompting user for credentials for 'https://github.com/'.
14:18:29.857721 ...\Git\Trace.cs:139    trace: [WriteException] ! error: 'An error occurred while sending the request.'.
14:18:29.859191 ...\Git\Trace.cs:143    trace: [WriteException]        > 'The underlying connection was closed: An unexpected error occurred on a send.'.
14:18:29.860691 ...\Git\Trace.cs:143    trace: [WriteException]        > 'Authentication failed because the remote party has closed the transport stream.'.
14:18:29.868367 ...\Common.cs:630       trace: [LogEvent] System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Authentication failed because the remote party has closed the transport stream.
   at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult)
   at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
   at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar)
   --- End of inner exception stack trace ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Alm.Authentication.Network.<HttpPostAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at GitHub.Authentication.Authority.<AcquireToken>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at GitHub.Authentication.Authentication.<InteractiveLogon>d__28.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Alm.Cli.CommonFunctions.<QueryCredentials>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Alm.Cli.Program.<>c__DisplayClass23_1.<<Get>b__0>d.MoveNext()
14:18:29.876004 ...\Program.cs:578      trace: [Run] fatal: HttpRequestException encountered.
   An error occurred while sending the request.
fatal: HttpRequestException encountered.
   An error occurred while sending the request.
14:18:30.142220 ...\Common.cs:665       trace: [Main] git-credential-manager (v1.16.2) 'get'
14:18:30.195361 ...\Git\Where.cs:343    trace: [FindGitInstallations] found 1 Git installation(s).
14:18:30.210949 ...Configuration.cs:222 trace: [LoadGitConfiguration] git All config read, 72 entries.
14:18:30.210949 ...\Common.cs:471       trace: [LoadOperationArguments] writeLog = 'True'.
14:18:30.210949 ...\Common.cs:284       trace: [EnableTraceLogging] trace logging enabled.
14:18:30.210949 ...\Common.cs:289       trace: [EnableTraceLogging] git local config found at 'C:\Users\ME\Documents\.git\config'.
14:18:30.210949 ...\Common.cs:344       trace: [EnableTraceLoggingFile] trace log destination is 'C:\Users\ME\Documents\.git'.
14:18:30.242199 ...\Common.cs:84        trace: [CreateAuthentication] detecting authority type for 'https://github.com/'.
14:18:30.260843 ...uthentication.cs:151 trace: [GetAuthentication] created GitHub authentication for 'https://github.com/'.
14:18:30.262344 ...\Common.cs:161       trace: [CreateAuthentication] authority for 'https://github.com/' is GitHub.
14:18:30.311231 ...icationPrompts.cs:59 trace: [CredentialModalPrompt] prompting user for credentials for 'https://github.com/'.
14:18:37.655478 ...\Git\Trace.cs:139    trace: [WriteException] ! error: 'An error occurred while sending the request.'.
14:18:37.656449 ...\Git\Trace.cs:143    trace: [WriteException]        > 'The underlying connection was closed: An unexpected error occurred on a send.'.
14:18:37.657450 ...\Git\Trace.cs:143    trace: [WriteException]        > 'Authentication failed because the remote party has closed the transport stream.'.
14:18:37.666994 ...\Common.cs:630       trace: [LogEvent] System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Authentication failed because the remote party has closed the transport stream.
   at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult)
   at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
   at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar)
   --- End of inner exception stack trace ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Alm.Authentication.Network.<HttpPostAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at GitHub.Authentication.Authority.<AcquireToken>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at GitHub.Authentication.Authentication.<InteractiveLogon>d__28.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Alm.Cli.CommonFunctions.<QueryCredentials>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Alm.Cli.Program.<>c__DisplayClass23_1.<<Get>b__0>d.MoveNext()
14:18:37.674995 ...\Program.cs:578      trace: [Run] fatal: HttpRequestException encountered.
   An error occurred while sending the request.
fatal: HttpRequestException encountered.
   An error occurred while sending the request.
Username for 'https://github.com': nbstrat
14:18:47.158920 ...\Common.cs:665       trace: [Main] git-credential-manager (v1.16.2) 'store'
14:18:47.212278 ...\Git\Where.cs:343    trace: [FindGitInstallations] found 1 Git installation(s).
14:18:47.227939 ...Configuration.cs:222 trace: [LoadGitConfiguration] git All config read, 72 entries.
14:18:47.227939 ...\Common.cs:471       trace: [LoadOperationArguments] writeLog = 'True'.
14:18:47.227939 ...\Common.cs:284       trace: [EnableTraceLogging] trace logging enabled.
14:18:47.227939 ...\Common.cs:289       trace: [EnableTraceLogging] git local config found at 'C:\Users\ME\Documents\.git\config'.
14:18:47.227939 ...\Common.cs:344       trace: [EnableTraceLoggingFile] trace log destination is 'C:\Users\ME\Documents\.git'.
14:18:47.243561 ...\Common.cs:84        trace: [CreateAuthentication] detecting authority type for 'https://nbstrat@github.com/'.
14:18:47.259154 ...uthentication.cs:151 trace: [GetAuthentication] created GitHub authentication for 'https://nbstrat@github.com/'.
14:18:47.259154 ...\Common.cs:161       trace: [CreateAuthentication] authority for 'https://nbstrat@github.com/' is GitHub.
14:18:47.259154 ...\Program.cs:502      trace: [Store] storing GitHub credentials for 'https://nbstrat@github.com/'.
14:18:47.259154 ...seSecureStore.cs:286 trace: [WriteCredential] credentials for 'git:https://github.com' written to store.
14:18:47.496806 ...\Common.cs:665       trace: [Main] git-credential-manager (v1.16.2) 'store'
14:18:47.543878 ...\Git\Where.cs:343    trace: [FindGitInstallations] found 1 Git installation(s).
14:18:47.543878 ...Configuration.cs:222 trace: [LoadGitConfiguration] git All config read, 72 entries.
14:18:47.559452 ...\Common.cs:471       trace: [LoadOperationArguments] writeLog = 'True'.
14:18:47.559452 ...\Common.cs:284       trace: [EnableTraceLogging] trace logging enabled.
14:18:47.559452 ...\Common.cs:289       trace: [EnableTraceLogging] git local config found at 'C:\Users\ME\Documents\.git\config'.
14:18:47.559452 ...\Common.cs:344       trace: [EnableTraceLoggingFile] trace log destination is 'C:\Users\ME\Documents\.git'.
14:18:47.575078 ...\Common.cs:84        trace: [CreateAuthentication] detecting authority type for 'https://nbstrat@github.com/'.
14:18:47.590703 ...uthentication.cs:151 trace: [GetAuthentication] created GitHub authentication for 'https://nbstrat@github.com/'.
14:18:47.592709 ...\Common.cs:161       trace: [CreateAuthentication] authority for 'https://nbstrat@github.com/' is GitHub.
14:18:47.593708 ...\Program.cs:502      trace: [Store] storing GitHub credentials for 'https://nbstrat@github.com/'.
14:18:47.597208 ...seSecureStore.cs:286 trace: [WriteCredential] credentials for 'git:https://github.com' written to store.
whoisj commented 6 years ago

Hmm... this looks like the TLS1.2 issue. GitHub has disabled support for weak encryption and there's a helpful topic on Developer Community that might help you.

nbstrat commented 6 years ago

I suspect that you are correct in that it is related to the TLS1.2 issue. I have read the information from the helpful topic on Developer Community link (multiple times) and have applied the two machine-wide registry keys for the .NET framework as indicated but still have the same issue and am at a loss. Other machines where the installation did not generate an error during the installation successfully connect to GitHub using credentials stored with GCM.

whoisj commented 6 years ago

@nbstrat using a tool like Fiddler (from Telerik) you can montior your HTTPS traffic and verify if the issue is TLS1.2 related for not.

The GCM sets the TLS1.2 flags early in its startup, so I know that it'll use TLS1.2 if available - this means that for some reason your machine is unable to meet the TLS1.2 requirement set forth by GitHub.

I believe TLS1.2 (on Windows) requires Vista or newer, .NET 4.5 or later, and up-to-date patches (this is from memory so ymmv).

nbstrat commented 6 years ago

I have confirmed that the connection is being made with TLS1.2 using Fiddler and have since upgraded my version of Visual Studio per the recommendations in the links provided (and confirmed that I have the latest .NET framework), but continue to have the same problem.

I continue to receive the "fatal: HttpRequestException encountered. An error occurred while sending the request." message on every push/pull to GitHub. The connection to GitHub is successful, but only after receiving the error and entering my git credential multiple times.

I have followed the recommendations from the links provided, but those appear to be for users unable to successfully connect which is not the case for my issue. I am able to connect, but must enter my credentials multiple times after getting the initial fatal: HttpRequestException encountered. An error occurred while sending the request." message.

Any additional suggestions appreciated.

whoisj commented 6 years ago

Are you still seeing the same error messages?

System.Net.Http.HttpRequestException: An error occurred while sending the request.
 -> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send.
   -> System.IO.IOException: Authentication failed because the remote party has closed the transport stream.
nbstrat commented 6 years ago

Yes, same error message.

whoisj commented 6 years ago

Yes, same error message.

Well, then the host is, most likely, refusing your connection. I have no way of knowing why.

@shiftkey any chance you, or another Githubber, have any insights into what is happening with @nbstrat here? On the surface it appears to be the TLS1.2 issue, but they report having done everything necessary to using TLS1.2. They even report having used Fiddler to confirm TLS1.2. So now I'm at a loss, any insights here would be very helpful and much appreciated.

vicpon commented 6 years ago

Me and my co-worker are also getting the same error with Bitbucket. Also confirmed with Fiddler that I'm using TSL 1.2.

shiftkey commented 6 years ago

@whoisj oops, I missed this ping.

For GitHub-related infrastructure queries, I'd reach out to GitHub support - if you're able to put Fiddler in between GCM and the network and find a X-GitHub-Request-Id response header that will greatly help with troubleshooting on our end. But I suspect if the TLS handshake is being rejected then that's going to occur before we even accept the request.

Also confirmed with Fiddler that I'm using TSL 1.2.

Please note that Fiddler needs to be enabled to support modern TLS versions and the applications calling through Fiddler might be reverting to using old TLS versions that are now unsupported.