如何使用 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/