You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CertificateCheckHandler callback uses a different return type in libgit2sharp compared to libgit2 #2195
In common with a number of others here, I'm having challenges getting certificates to work in C# code. I've gotten to proving the there is a difference in data types expected from the certificate check callback used by C and C#, documented differences in the "valid" value, and very different enumerations for the certificate types.
libgit2sharp Handlers.cs has
public delegate bool CertificateCheckHandler(Certificate certificate, bool valid, string host);
meanwhile, libgit2 cert.h has:
typedef int GIT_CALLBACK(git_transport_certificate_cb)(git_cert cert, int valid, const charhost, void *payload);
The C int return and C# bool return are treated in ways that can mean opposite treatment:
C# uses 'true' (certificate valid) and 'false'.
C uses: 0 = proceed (certificate valid)
<0 = fail the connection
>0 = callback failed to act, use the existing validity determination.
Since a 'true' is a '1' is >0, there needs to be a shim of code to translate the result or the documented use (return true to say the certificate is valid) isn't producing the expected value. I've been unable to dig deep enough to locate the shim, could someone with more knowledge take a closer look?
Activity