Git 使用 LibGit2Sharp 抛出公司防火墙后的网络操作
Git network operations behind corporate firewall using LibGit2Sharp throws
我正在尝试使用 LibGit2Sharp to git push origin
使用以下
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);
}
我得到一个 LibGit2SharpException 说
Additional information: Failed to set proxy: The parameter is incorrect.
但是在 git bash 中,当我 git push origin
时一切都很好。
我们有 NTLM 代理在工作,我正在推送到 Intranet https 远程 URI。我在下面将代理配置为 http://username:password@proxy.fqdn:80
:
- 环境变量:HTTP_PROXY & HTTPS_PROXY
- 回购。git/config:
- remote.origin.proxy
- http.proxy
- https.proxy
- http.sslCAInfo & https.sslCAInfo - 这是主机
的根 CA 路径
通读 this SO and links there 后,libgit2sharp 似乎应该可以很好地找到代理参数。有没有人让这个在 ntlm 下工作?
我正在使用:
Windows7,库Git2Sharp.0.22.0,Git2.10.1.windows.1,bash4.3.46,.net4.5.2
也非常欢迎任何 ideas/tricks 通过替代方案实现推送!
本文来自“libgit2 src/transports/winhttp.c
", which calls directly the Windows API WinHttpSetOption
function.
它传递一个 WINHTTP_OPTION_PROXY
to set or retrieves an WINHTTP_PROXY_INFO
结构,该结构包含现有会话句柄或请求句柄上的代理数据。
那个函数returns ERROR_INVALID_PARAMETER
(参数无效)仅当WINHTTP_OPTION_WEB_SOCKET_KEEPALIVE_INTERVAL
设置为低于15000
的值。
我不知道为什么 LibGit2Sharp 有这个问题,但首先尝试只设置环境变量 HTTP_PROXY
& HTTPS_PROXY
(不是 http.proxy
& https.proxy
),并确保对两个代理环境变量使用相同的 http url(不是 HTTPS_PROXY
的 https url)
关于此的官方 libgit2 错误是 issue 2106, which is supposed to be resolved with PR 3110, and commit 1dc4491。
但是,该修复 尚未 发布。
我正在尝试使用 LibGit2Sharp to git push origin
使用以下
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);
}
我得到一个 LibGit2SharpException 说
Additional information: Failed to set proxy: The parameter is incorrect.
但是在 git bash 中,当我 git push origin
时一切都很好。
我们有 NTLM 代理在工作,我正在推送到 Intranet https 远程 URI。我在下面将代理配置为 http://username:password@proxy.fqdn:80
:
- 环境变量:HTTP_PROXY & HTTPS_PROXY
- 回购。git/config:
- remote.origin.proxy
- http.proxy
- https.proxy
- http.sslCAInfo & https.sslCAInfo - 这是主机 的根 CA 路径
通读 this SO and links there 后,libgit2sharp 似乎应该可以很好地找到代理参数。有没有人让这个在 ntlm 下工作?
我正在使用: Windows7,库Git2Sharp.0.22.0,Git2.10.1.windows.1,bash4.3.46,.net4.5.2
也非常欢迎任何 ideas/tricks 通过替代方案实现推送!
本文来自“libgit2 src/transports/winhttp.c
", which calls directly the Windows API WinHttpSetOption
function.
它传递一个 WINHTTP_OPTION_PROXY
to set or retrieves an WINHTTP_PROXY_INFO
结构,该结构包含现有会话句柄或请求句柄上的代理数据。
那个函数returns ERROR_INVALID_PARAMETER
(参数无效)仅当WINHTTP_OPTION_WEB_SOCKET_KEEPALIVE_INTERVAL
设置为低于15000
的值。
我不知道为什么 LibGit2Sharp 有这个问题,但首先尝试只设置环境变量 HTTP_PROXY
& HTTPS_PROXY
(不是 http.proxy
& https.proxy
),并确保对两个代理环境变量使用相同的 http url(不是 HTTPS_PROXY
的 https url)
关于此的官方 libgit2 错误是 issue 2106, which is supposed to be resolved with PR 3110, and commit 1dc4491。
但是,该修复 尚未 发布。