1

我正在使用 pygit2 以编程方式从拥有自签名证书的内部服务器克隆存储库。pygit2 在证书上引发错误,如何关闭验证?

4

1 回答 1

0

该检查是因为pygit2/remote.py#L170-L175

def _fill_fetch_options(self, fetch_opts):
    fetch_opts.callbacks.certificate_check = self._certificate_cb

这个问题中,您可以用自己的(什么都不做)为git_fetch_optionsstruct覆盖回调函数。

git_fetch_options options = GIT_FETCH_OPTIONS_VERSION;
options.git_remote_callbacks.certificate_check = my_own_cred_acquire_cb;

这种方法在 pygit2 上的 OP 自己的问题中得到了回应和确认:

您不能告诉 pygit2/libgit2 忽略所有内容,但您可以提供自己的证书验证函数作为回调。
如果您设置certificate_check为您编写的某个函数,则可以忽略已知错误主机的证书。

于 2016-04-26T06:48:05.477 回答