1

I'm using pygit2 to programmatically clone a repo from an internal server which holds a self-signed certificate. The pygit2 raises an error on the certificate, how do I turn the verification off?

user3236929
  • 123
  • 1
  • 2
  • 7

1 Answers1

0

That check is done because of pygit2/remote.py#L170-L175

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

As in this question, you could override the callback function with your own (which would do nothing) for the git_fetch_options struct.

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

This approach is echoed and confirmed in the OP's own issue on pygit2:

You can't tell pygit2/libgit2 to ignore everything, but you can provide your own certificate validation function as a callback.
If you set certificate_check to some function you write, you can ignore the certificate for your known-bad host.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • thank you, i overrode the certificate_check and always returns True but still failed. an error raised with the saying "to many redirects". https://github.com/libgit2/pygit2/issues/627 – user3236929 Apr 28 '16 at 03:10