How to clone with disabled SSL checking, using GitPython library. The following code ...
import git
x = git.Repo.clone_from('https://xxx', '/home/xxx/lala')
... yields this error:
Error: fatal: unable to access 'xxx': server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
I know about "export GIT_SSL_NO_VERIFY=1", but how to implement it in a python library ?
The two following methods have been tested with GitPython 2.0.8 but should be working at least since 1.0.2 (from the doc).
As suggested by @Byron:
git.Repo.clone_from(
'https://example.net/path/to/repo.git',
'local_destination',
branch='master', depth=1,
env={'GIT_SSL_NO_VERIFY': '1'},
)
As suggested by @Christopher:
git.Repo.clone_from(
'https://example.net/path/to/repo.git',
'local_destination',
branch='master', depth=1,
config='http.sslVerify=false',
)
It seems easiest to pass the GIT_SSL_NO_VERIFY environment variable to all git invocations. Unfortunately Git.update_environment(...) can only be used on an existing instance, which is why you would have to manipulate python's environment like so:
import git
import os
os.environ['GIT_SSL_NO_VERIFY'] = "1"
repo = git.Repo.clone_from('https://xxx', '/home/xxx/lala')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With