ssl - 使用 GitPython 库的 git clone

标签 ssl gitpython

如何使用 GitPython 库在禁用 SSL 检查的情况下进行克隆。下面的代码……

import git
x = git.Repo.clone_from('https://xxx', '/home/xxx/lala')

...产生此错误:

Error: fatal: unable to access 'xxx': server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none

我知道“export GIT_SSL_NO_VERIFY=1”,但如何在 python 库中实现它?

最佳答案

以下两种方法已经用 GitPython 2.0.8 进行了测试,但应该至少从 1.0.2 开始就可以工作(来自文档)。

正如@Byron 所建议的:

git.Repo.clone_from(
  'https://example.net/path/to/repo.git',
  'local_destination',
  branch='master', depth=1,
  env={'GIT_SSL_NO_VERIFY': '1'},
)

根据 @Christopher 的建议:

git.Repo.clone_from(
  'https://example.net/path/to/repo.git',
  'local_destination',
  branch='master', depth=1,
  config='http.sslVerify=false',
)

关于ssl - 使用 GitPython 库的 git clone,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31581902/

相关文章:

java - 使用来自 Java 的证书登录网页

ssl - 带有证书的 lua https.request

python - 如何使用 GitPython 标记特定提交

ssl - CloudFront 和 EC2 Origin 之间的 SSL 证书使用什么 Origin 和 ServerName?

c++ - 如何在 OpenSSL 中获取 SSL 证书

javascript - Node : Determine whether a website supports SSL based on a url without protocol

python-3.x - 识别 git 提交的实际分支名称

python - 获取提交的标签

python - 如何使用 GitPython 进行 pull ?

python - 使用 GitPython + SSH key 进行 Git pull 不起作用