Skip to content

Commit

Permalink
Separate functions for SSL CA file / path
Browse files Browse the repository at this point in the history
  • Loading branch information
aharbis committed Nov 3, 2023
1 parent f43a7e2 commit 7520761
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions src/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,22 +195,38 @@ pub unsafe fn set_verify_owner_validation(enabled: bool) -> Result<(), Error> {
Ok(())
}

/// Set the SSL certificate-authority locations. `file` is the location of a file containing
/// several certificates concatenated together. `path` is the location of a directory holding
/// several certificates, one per file. Either parameter may be `None`, but not both.
pub unsafe fn set_ssl_cert_locations<P>(file: Option<P>, path: Option<P>) -> Result<(), Error>
/// 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();
let file = crate::opt_cstr(file)?;
let path = crate::opt_cstr(path)?;

unsafe {
try_call!(raw::git_libgit2_opts(
raw::GIT_OPT_SET_SSL_CERT_LOCATIONS as libc::c_int,
file,
path
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()
));
}

Expand Down

0 comments on commit 7520761

Please sign in to comment.