From 7e0591a3776c9c919a0fc8a3effdde3cb17ce77b Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Wed, 21 Feb 2018 23:25:28 -0800 Subject: [PATCH] Actually add version stuff --- CHANGELOG.md | 14 +++++++++----- openssl/src/ssl/mod.rs | 18 ++++++++++++++++-- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b716073e..0d3a5b38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ ## [Unreleased] +### Added + +* Added `SslRef::version2`. + +### Deprecated + +* `SslRef::version` has been deprecated. Use `SslRef::version_str` instead. + ## [v0.10.4] - 2018-02-18 ### Added @@ -9,7 +17,7 @@ * Added OpenSSL 1.1.1 support. * Added `Rsa::public_key_from_pem_pkcs1`. * Added `SslOptions::NO_TLSV1_3`. (OpenSSL 1.1.1 only) -* Added `SslVersion` and `SslRef::version2`. +* Added `SslVersion`. * Added `SslSessionCacheMode` and `SslContextBuilder::set_session_cache_mode`. * Added `SslContextBuilder::set_new_session_callback`, `SslContextBuilder::set_remove_session_callback`, and @@ -22,10 +30,6 @@ * The `SslAcceptorBuilder::mozilla_modern` constructor now disables TLSv1.0 and TLSv1.1 in accordance with Mozilla's recommendations. -### Deprecated - -* `SslRef::version` has been deprecated. Use `SslRef::version_str` instead. - ## [v0.10.3] - 2018-02-12 ### Added diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs index 69d38f44..e4796df0 100644 --- a/openssl/src/ssl/mod.rs +++ b/openssl/src/ssl/mod.rs @@ -1957,12 +1957,26 @@ impl SslRef { } } + #[deprecated(since = "0.10.5", note = "renamed to `version_str`")] + pub fn version(&self) -> &str { + self.version_str() + } + + /// Returns the protocol version of the session. + /// + /// This corresponds to [`SSL_version`]. + /// + /// [`SSL_version`]: https://www.openssl.org/docs/manmaster/man3/SSL_version.html + pub fn version2(&self) -> SslVersion { + unsafe { SslVersion(ffi::SSL_version(self.as_ptr())) } + } + /// Returns a string describing the protocol version of the session. /// /// This corresponds to [`SSL_get_version`]. /// /// [`SSL_get_version`]: https://www.openssl.org/docs/man1.1.0/ssl/SSL_get_version.html - pub fn version(&self) -> &'static str { + pub fn version_str(&self) -> &'static str { let version = unsafe { let ptr = ffi::SSL_get_version(self.as_ptr()); CStr::from_ptr(ptr as *const _) @@ -2004,7 +2018,7 @@ impl SslRef { /// If this is greater than 0, the next call to `read` will not call down to the underlying /// stream. /// - /// This corresponds to [`SSL_pending]`. + /// This corresponds to [`SSL_pending`]. /// /// [`SSL_pending`]: https://www.openssl.org/docs/man1.1.0/ssl/SSL_pending.html pub fn pending(&self) -> usize {