From 625205de6fd3169101ce36468d9471b6cb686f75 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Wed, 23 Dec 2020 21:11:29 -0500 Subject: Fix argument type of Ssl::new --- openssl/src/ssl/mod.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'openssl') diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs index 199e33b6..f60b1ee1 100644 --- a/openssl/src/ssl/mod.rs +++ b/openssl/src/ssl/mod.rs @@ -1823,6 +1823,14 @@ foreign_type_and_impl_send_sync! { impl Clone for SslContext { fn clone(&self) -> Self { + (**self).to_owned() + } +} + +impl ToOwned for SslContextRef { + type Owned = SslContext; + + fn to_owned(&self) -> Self::Owned { unsafe { SSL_CTX_up_ref(self.as_ptr()); SslContext::from_ptr(self.as_ptr()) @@ -2381,11 +2389,11 @@ impl Ssl { /// /// [`SSL_new`]: https://www.openssl.org/docs/man1.0.2/ssl/SSL_new.html // FIXME should take &SslContextRef - pub fn new(ctx: &SslContext) -> Result { + pub fn new(ctx: &SslContextRef) -> Result { unsafe { let ptr = cvt_p(ffi::SSL_new(ctx.as_ptr()))?; let mut ssl = Ssl::from_ptr(ptr); - ssl.set_ex_data(*SESSION_CTX_INDEX, ctx.clone()); + ssl.set_ex_data(*SESSION_CTX_INDEX, ctx.to_owned()); Ok(ssl) } -- cgit v1.2.3