Skip to content

Commit 7520761

Browse files
committed
Separate functions for SSL CA file / path
1 parent f43a7e2 commit 7520761

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

src/opts.rs

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,22 +195,38 @@ pub unsafe fn set_verify_owner_validation(enabled: bool) -> Result<(), Error> {
195195
Ok(())
196196
}
197197

198-
/// Set the SSL certificate-authority locations. `file` is the location of a file containing
199-
/// several certificates concatenated together. `path` is the location of a directory holding
200-
/// several certificates, one per file. Either parameter may be `None`, but not both.
201-
pub unsafe fn set_ssl_cert_locations<P>(file: Option<P>, path: Option<P>) -> Result<(), Error>
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>
202201
where
203202
P: IntoCString,
204203
{
205204
crate::init();
206-
let file = crate::opt_cstr(file)?;
207-
let path = crate::opt_cstr(path)?;
208205

209206
unsafe {
210207
try_call!(raw::git_libgit2_opts(
211208
raw::GIT_OPT_SET_SSL_CERT_LOCATIONS as libc::c_int,
212-
file,
213-
path
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()
214230
));
215231
}
216232

0 commit comments

Comments
 (0)