Open kevinvalk opened 6 months ago
Super ugly monkey patch to get certificate_check
working in version 1.13.3 of pygit2
class MyCallbacks(pygit2.RemoteCallbacks):
def certificate_check(testrepo, certificate, valid, host):
logging.error("Yes I bypass stuff")
return True
def __setattr__(self, name: str, value: Any) -> None:
if name == "remote_callbacks":
from pygit2.ffi import C
value.certificate_check = C._certificate_cb
return super().__setattr__(name, value)
As far as I can see the remote_callbacks struct is not properly initialized with the
certificate_check
callback (https://libgit2.org/libgit2/#v0.23.2/type/git_remote_callbacks).https://github.com/libgit2/pygit2/blob/611a3b3462a1acb6bc3ca0d9bd3eff7bf6154131/pygit2/callbacks.py#L384-L387
This makes it impossible to "bypass" certificate checks for example when testing remotes. So I think simply adding to the callback options is enough, but do not quote me on that!
This also may be the problem for https://github.com/libgit2/pygit2/issues/945
P.S. Its point about
certificate_check
vscertificate
still stands so that could also be sorted out.