Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 25 additions & 18 deletions src/remote_callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,27 +412,34 @@ extern "C" fn update_tips_cb(

extern "C" fn certificate_check_cb(
cert: *mut raw::git_cert,
_valid: c_int,
valid: c_int,
hostname: *const c_char,
data: *mut c_void,
) -> c_int {
let ok = panic::wrap(|| unsafe {
let payload = &mut *(data as *mut RemoteCallbacks<'_>);
let callback = match payload.certificate_check {
Some(ref mut c) => c,
None => return Ok(CertificateCheckStatus::CertificatePassthrough),
};
let cert = Binding::from_raw(cert);
let hostname = str::from_utf8(CStr::from_ptr(hostname).to_bytes()).unwrap();
callback(&cert, hostname)
});
match ok {
Some(Ok(CertificateCheckStatus::CertificateOk)) => 0,
Some(Ok(CertificateCheckStatus::CertificatePassthrough)) => raw::GIT_PASSTHROUGH as c_int,
Some(Err(e)) => unsafe { e.raw_set_git_error() },
None => {
// Panic. The *should* get resumed by some future call to check().
-1
match valid {
1 => valid,
_ => {
let ok = panic::wrap(|| unsafe {
let payload = &mut *(data as *mut RemoteCallbacks<'_>);
let callback = match payload.certificate_check {
Some(ref mut c) => c,
None => return Ok(CertificateCheckStatus::CertificatePassthrough),
};
let cert = Binding::from_raw(cert);
let hostname = str::from_utf8(CStr::from_ptr(hostname).to_bytes()).unwrap();
callback(&cert, hostname)
});
match ok {
Some(Ok(CertificateCheckStatus::CertificateOk)) => 0,
Some(Ok(CertificateCheckStatus::CertificatePassthrough)) => {
raw::GIT_PASSTHROUGH as c_int
}
Some(Err(e)) => unsafe { e.raw_set_git_error() },
None => {
// Panic. The *should* get resumed by some future call to check().
-1
}
}
}
}
}
Expand Down