From 7520761f4e2727db5c0cc9a21e72b5a606a2e3e7 Mon Sep 17 00:00:00 2001 From: Aidan Harbison Date: Fri, 3 Nov 2023 12:41:15 -0400 Subject: [PATCH] Separate functions for SSL CA file / path --- src/opts.rs | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/opts.rs b/src/opts.rs index 270333b6c1..c709fd0c22 100644 --- a/src/opts.rs +++ b/src/opts.rs @@ -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

(file: Option

, path: Option

) -> 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

(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::() + )); + } + + 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

(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::(), + path.into_c_string()?.as_ptr() )); }