From 8ab1873d8bbc842a65686a8809267786ee8becb8 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Wed, 7 Feb 2024 12:46:18 +0100 Subject: [PATCH] Introduce SslRef::set_private_key --- boring/src/ssl/mod.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/boring/src/ssl/mod.rs b/boring/src/ssl/mod.rs index 6b407490..2f27b2ed 100644 --- a/boring/src/ssl/mod.rs +++ b/boring/src/ssl/mod.rs @@ -3563,6 +3563,18 @@ impl SslRef { Ok(()) } + + /// Sets the private key. + /// + /// This corresponds to [`SSL_use_PrivateKey`]. + /// + /// [`SSL_use_PrivateKey`]: https://www.openssl.org/docs/man1.1.1/man3/SSL_use_PrivateKey.html + pub fn set_private_key(&mut self, key: &PKeyRef) -> Result<(), ErrorStack> + where + T: HasPrivate, + { + unsafe { cvt(ffi::SSL_use_PrivateKey(self.as_ptr(), key.as_ptr())).map(|_| ()) } + } } /// An SSL stream midway through the handshake process.