Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

certificate_check callback not used in remote.connect or remote.ls_remotes #1262

Open
kevinvalk opened this issue Dec 30, 2023 · 1 comment

Comments

@kevinvalk
Copy link

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).

pygit2/pygit2/callbacks.py

Lines 384 to 387 in 611a3b3

# Plug callbacks
cdata.credentials = C._credentials_cb
cdata.update_tips = C._update_tips_cb
# Payload

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!

cdata.certificate_check = C._certificate_cb

This also may be the problem for #945

P.S. Its point about certificate_check vs certificate still stands so that could also be sorted out.

@kevinvalk
Copy link
Author

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)

sathieu added a commit to sathieu/pygit2 that referenced this issue Oct 10, 2024
sathieu added a commit to sathieu/pygit2 that referenced this issue Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant