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

Implement valid parameter for RemoteCallbacks::certificate_check #1146

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

brysonsteck
Copy link

In the RemoteCallbacks struct documentation, the certificate_check function has this description:

If certificate verification fails, then this callback will be invoked to let the caller make the final decision of whether to allow the connection to proceed.

However, this statement is false. It turns out that this function never actually checks if the certificate is valid using the cert_valid parameter passed into certificate_check_cb from the check_certificate function in libgit2. As a result, when a callback function is specified, the function will always run regardless if libgit2 marks it valid.

I made the change in the function specified to skip the callback if the certificate is valid (valid = 1). Before, any SSH remotes would run this callback, and now only hosts that do not appear in my hosts file (~/.ssh/known_hosts) will result in the callback being ran.

If there are any changes I need to make, let me know! :)

@rustbot rustbot added the S-waiting-on-review Status: Waiting on review label Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Waiting on review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants