From 6baba64eec90f934736c022dc7b2cd45407eca32 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Tue, 13 Apr 2021 11:59:27 +0200 Subject: [PATCH 1/2] Allow returning the server name from the early callback --- boring/src/ssl/mod.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/boring/src/ssl/mod.rs b/boring/src/ssl/mod.rs index a3bbc48f..7d0d5f89 100644 --- a/boring/src/ssl/mod.rs +++ b/boring/src/ssl/mod.rs @@ -1779,6 +1779,15 @@ impl ClientHello { Some(slice::from_raw_parts(ptr, len)) } } + + fn ssl(&self) -> &SslRef { + unsafe { SslRef::from_ptr(self.0.ssl) } + } + + /// Returns the servername sent by the client via Server Name Indication (SNI). + pub fn servername(&self, type_: NameType) -> Option<&str> { + self.ssl().servername(type_) + } } /// Information about a cipher. From d147f155a44d191a0a825890397261580f1dd4af Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Tue, 13 Apr 2021 12:03:55 +0200 Subject: [PATCH 2/2] Allow retrieving the version string from early callback --- boring/src/ssl/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/boring/src/ssl/mod.rs b/boring/src/ssl/mod.rs index 7d0d5f89..50d2b059 100644 --- a/boring/src/ssl/mod.rs +++ b/boring/src/ssl/mod.rs @@ -1788,6 +1788,11 @@ impl ClientHello { pub fn servername(&self, type_: NameType) -> Option<&str> { self.ssl().servername(type_) } + + /// Returns a string describing the protocol version of the session. + pub fn version_str(&self) -> &'static str { + self.ssl().version_str() + } } /// Information about a cipher.