From 32492cd4f012a5b80bf7024706b8787c02b8eca0 Mon Sep 17 00:00:00 2001 From: 0x676e67 Date: Fri, 7 Feb 2025 12:19:41 +0800 Subject: [PATCH] feat: Add `set_options` binding function to ConnectConfiguration (#43) --- boring/src/ssl/connector.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/boring/src/ssl/connector.rs b/boring/src/ssl/connector.rs index c403146d..5f4759c2 100644 --- a/boring/src/ssl/connector.rs +++ b/boring/src/ssl/connector.rs @@ -314,6 +314,24 @@ impl ConnectConfiguration { pub fn set_alps_use_new_codepoint(&mut self, use_new: bool) { unsafe { ffi::SSL_set_alps_use_new_codepoint(self.as_ptr(), use_new as _) } } + + /// Sets the SSL options. + /// + /// # Arguments + /// + /// * `options` - An `SslOptions` bitmask representing the options to set. + /// + /// # Returns + /// + /// * `Result<(), ErrorStack>` - Returns `Ok(())` if the operation is successful, otherwise returns an `ErrorStack`. + /// + /// # Safety + /// + /// This function is unsafe because it calls an FFI function. + #[corresponds(SSL_set_options)] + pub fn set_options(&mut self, options: SslOptions) -> Result<(), ErrorStack> { + unsafe { cvt(ffi::SSL_set_options(self.as_ptr(), options.bits()) as _).map(|_| ()) } + } } impl Deref for ConnectConfiguration {