Skip to content

Commit

Permalink
Merge pull request #997 from aharbis/opts-ssl-cert
Browse files Browse the repository at this point in the history
Add binding for GIT_OPT_SET_SSL_CERT_LOCATIONS
  • Loading branch information
ehuss authored Nov 3, 2023
2 parents dc63db5 + 7520761 commit fd4d7c7
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,44 @@ pub unsafe fn set_verify_owner_validation(enabled: bool) -> Result<(), Error> {
Ok(())
}

/// Set the SSL certificate-authority location to `file`. `file` is the location
/// of a file containing several certificates concatenated together.
pub unsafe fn set_ssl_cert_file<P>(file: P) -> Result<(), Error>
where
P: IntoCString,
{
crate::init();

unsafe {
try_call!(raw::git_libgit2_opts(
raw::GIT_OPT_SET_SSL_CERT_LOCATIONS as libc::c_int,
file.into_c_string()?.as_ptr(),
core::ptr::null::<libc::c_char>()
));
}

Ok(())
}

/// Set the SSL certificate-authority location to `path`. `path` is the location
/// of a directory holding several certificates, one per file.
pub unsafe fn set_ssl_cert_dir<P>(path: P) -> Result<(), Error>
where
P: IntoCString,
{
crate::init();

unsafe {
try_call!(raw::git_libgit2_opts(
raw::GIT_OPT_SET_SSL_CERT_LOCATIONS as libc::c_int,
core::ptr::null::<libc::c_char>(),
path.into_c_string()?.as_ptr()
));
}

Ok(())
}

#[cfg(test)]
mod test {
use super::*;
Expand Down

0 comments on commit fd4d7c7

Please sign in to comment.