LibGit2Sharp 未知证书查找失败:16777280

问题描述 投票:0回答:1

我在自定义 git 客户端中使用 LibGit2Sharp,在我的机器上运行良好,但是当我使用相同的凭据在不同的机器上运行相同的代码时,我收到错误:

未知证书查找失败:16777280

我做了一些谷歌搜索,看起来它与身份验证证书有关,但当我克隆 HTTPS 时,我认为提供 gitlab 用户的用户名和密码就足够了?

无论如何,有人可以指导我解决这个问题吗?这有点超出我的知识范围,也是我第一次使用 git API。

这是我正在使用的代码。重申一下,它在我自己的机器上完美运行,但在另一台机器上则不然。

public void Clone()
{
    // Notify about the cloning process initiation
    this.OnUpdate?.Invoke(this, new OnUpdateEventArgs
    {
        Severity = LogType.Info,
        Message = $"Cloning the repository {this.RepositoryInfo.Name}"
    });

    try
    {
        // Clone the repository with credentials
        Repository.Clone(this.RepositoryInfo.RemoteRepository, this.RepositoryInfo.LocalRepository.FullName,
            new CloneOptions
            {
                FetchOptions = { CredentialsProvider = (url, user, cred) => new UsernamePasswordCredentials { Username = this.Author.Credentials.UserName, Password = this.Author.Credentials.Password } }
            });

        // Notify about the successful cloning
        this.OnUpdate?.Invoke(this, new OnUpdateEventArgs
        {
            Severity = LogType.Success,
            Message = "Repository cloned successfully."
        });
    }
    catch (Exception e)
    {
        // Notify about the error during cloning
        this.OnUpdate?.Invoke(this, new OnUpdateEventArgs
        {
            Severity = LogType.Error,
            Message = Errors.GetErrorString(86) + " : " + e.Message
        });
    }
}
libgit2sharp
1个回答
0
投票

此错误来自 SSL 证书检查。可能在您的环境中,证书是受信任的(例如,通过公司根证书),但在其他计算机上则不然。如果您在另一台计算机上运行 git 克隆,您应该会收到类似的错误,或者显示证书检查已被禁用的消息。看一下 https://github.com/libgit2/libgit2sharp/issues/1290,那里提供了一个解决方法(虽然不适合我,可能还有另一个问题)。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.