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

Add binding for GIT_OPT_SET_SSL_CERT_LOCATIONS #997

Merged
merged 2 commits into from
Nov 3, 2023
Merged
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
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