Skip to content

Commit fd4d7c7

Browse files
authored
Merge pull request #997 from aharbis/opts-ssl-cert
Add binding for GIT_OPT_SET_SSL_CERT_LOCATIONS
2 parents dc63db5 + 7520761 commit fd4d7c7

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/opts.rs

+38
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,44 @@ pub unsafe fn set_verify_owner_validation(enabled: bool) -> Result<(), Error> {
195195
Ok(())
196196
}
197197

198+
/// Set the SSL certificate-authority location to `file`. `file` is the location
199+
/// of a file containing several certificates concatenated together.
200+
pub unsafe fn set_ssl_cert_file<P>(file: P) -> Result<(), Error>
201+
where
202+
P: IntoCString,
203+
{
204+
crate::init();
205+
206+
unsafe {
207+
try_call!(raw::git_libgit2_opts(
208+
raw::GIT_OPT_SET_SSL_CERT_LOCATIONS as libc::c_int,
209+
file.into_c_string()?.as_ptr(),
210+
core::ptr::null::<libc::c_char>()
211+
));
212+
}
213+
214+
Ok(())
215+
}
216+
217+
/// Set the SSL certificate-authority location to `path`. `path` is the location
218+
/// of a directory holding several certificates, one per file.
219+
pub unsafe fn set_ssl_cert_dir<P>(path: P) -> Result<(), Error>
220+
where
221+
P: IntoCString,
222+
{
223+
crate::init();
224+
225+
unsafe {
226+
try_call!(raw::git_libgit2_opts(
227+
raw::GIT_OPT_SET_SSL_CERT_LOCATIONS as libc::c_int,
228+
core::ptr::null::<libc::c_char>(),
229+
path.into_c_string()?.as_ptr()
230+
));
231+
}
232+
233+
Ok(())
234+
}
235+
198236
#[cfg(test)]
199237
mod test {
200238
use super::*;

0 commit comments

Comments
 (0)