]> git.proxmox.com Git - cargo.git/blobdiff - vendor/openssl/src/provider.rs
New upstream version 0.66.0+pve1
[cargo.git] / vendor / openssl / src / provider.rs
index 72d54f41dce3fb1bf8e27d0230ea3270fd80b37b..147fadfdbc4d84b926e8c7c8fc6322615ef9d324 100644 (file)
@@ -1,6 +1,6 @@
-use crate::cvt_p;
 use crate::error::ErrorStack;
 use crate::lib_ctx::LibCtxRef;
+use crate::{cvt, cvt_p};
 use foreign_types::{ForeignType, ForeignTypeRef};
 use openssl_macros::corresponds;
 use std::ffi::CString;
@@ -58,4 +58,20 @@ impl Provider {
             Ok(Provider::from_ptr(p))
         }
     }
+
+    /// Specifies the default search path that is to be used for looking for providers in the specified library context.
+    /// If left unspecified, an environment variable and a fall back default value will be used instead
+    ///
+    /// If `ctx` is `None`, the provider will be loaded into the default library context.
+    #[corresponds(OSSL_PROVIDER_set_default_search_path)]
+    pub fn set_default_search_path(ctx: Option<&LibCtxRef>, path: &str) -> Result<(), ErrorStack> {
+        let path = CString::new(path).unwrap();
+        unsafe {
+            cvt(ffi::OSSL_PROVIDER_set_default_search_path(
+                ctx.map_or(ptr::null_mut(), ForeignTypeRef::as_ptr),
+                path.as_ptr(),
+            ))
+            .map(|_| ())
+        }
+    }
 }