From 9b821cf3da2307d4be47bc989123b946a0daa47a Mon Sep 17 00:00:00 2001 From: Fisher Darling Date: Fri, 24 Nov 2023 13:30:14 +0100 Subject: [PATCH] Allow access to a Connection's boring::ssl::SslRef We would like to modify extension data in an SslRef to support async callbacks. To do so we need access to a Connection's `SslRef`. --- quiche/src/lib.rs | 7 +++++++ quiche/src/tls.rs | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/quiche/src/lib.rs b/quiche/src/lib.rs index 5ed2723de2..cf0693f43b 100644 --- a/quiche/src/lib.rs +++ b/quiche/src/lib.rs @@ -7438,6 +7438,13 @@ impl Connection { } } +#[cfg(feature = "boringssl-boring-crate")] +impl AsMut for Connection { + fn as_mut(&mut self) -> &mut boring::ssl::SslRef { + self.handshake.ssl_mut() + } +} + /// Maps an `Error` to `Error::Done`, or itself. /// /// When a received packet that hasn't yet been authenticated triggers a failure diff --git a/quiche/src/tls.rs b/quiche/src/tls.rs index 04bda715ea..2325dfcc80 100644 --- a/quiche/src/tls.rs +++ b/quiche/src/tls.rs @@ -898,6 +898,13 @@ impl Handshake { } } } + + #[cfg(feature = "boringssl-boring-crate")] + pub(crate) fn ssl_mut(&mut self) -> &mut boring::ssl::SslRef { + use foreign_types_shared::ForeignTypeRef; + + unsafe { boring::ssl::SslRef::from_ptr_mut(self.as_mut_ptr() as _ ) } + } } // NOTE: These traits are not automatically implemented for Handshake due to the