Git network operations behind a corporate firewall using LibGit2Sharp throws

I am trying to use LibGit2Sharp for git push origin using the following

 using(var repo = new Repository("path\to\repo\.git")) { var commit = repo.Commit("Commit message", author, committer); var options = new PushOptions{ CredentialsProvider = (u, s, t) => new UserNamePasswordCredentials { Username = "username", Password = "password" } }; repo.Network.Push(repo.Branches("master"), options); } 

I get a LibGit2SharpException message saying

Additional information: Failed to install proxy: parameter is incorrect.

But in git bash, everything is fine when I do git push origin .

We have an NTLM proxy at work, and I click on the remote URI for intranet https. I configured the proxy as http://username: password@proxy.fqdn :80 in the following:

  • Env vars: HTTP_PROXY and HTTPS_PROXY
  • repos.git / config:
    • remote.origin.proxy
    • http.proxy
    • https.proxy
    • http.sslCAInfo and https.sslCAInfo is the path to the root CA for the host

After reading this SO and the links there , it seems like libgit2sharp should just find the proxy setting. Has anyone got this to work with ntlm?

I use: Windows 7, LibGit2Sharp.0.22.0, git 2.10.1.windows.1, bash 4.3.46, .net4.5.2

Any ideas / tricks to achieve the push through the alternative are also very welcome!

+5
source share
1 answer

This comes from libgit2 src/transports/winhttp.c ", which calls the WinHttpSetOption Windows API directly.

It passes WINHTTP_OPTION_PROXY to set or receive WINHTTP_PROXY_INFO , which contains proxy data for an existing session descriptor or request descriptor.

This function returns ERROR_INVALID_PARAMETER (parameter is not valid) only if WINHTTP_OPTION_WEB_SOCKET_KEEPALIVE_INTERVAL set to a value below 15000 .

I don’t know why LibGit2Sharp has this problem, but first try setting only the http.proxy and https.proxy environment variables (not http.proxy and https.proxy ) and be sure to use the same http url for both proxy environment variables (not https url for HTTPS_PROXY )

The official libgit2 error on this is problem 2106 , which must be resolved with PR 3110 and fix 1dc4491 .
However, this fix is ​​not yet included in the release.

0
source

Source: https://habr.com/ru/post/1257825/


All Articles