rust: bssl-tls: Fix predicate on `established` Update-Note: `TlsConnection::established` previously returns a handle if the session is present. This is mostly true except when a session resumption is configured. At this point the handshake is most likely not truly completed. This patch aligns with the intended meaning that this function implies. Signed-off-by: Xiangfei Ding <xfding@google.com> Change-Id: I3c06c692b2dc6478f55dde57e493b1226a6a6964 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/98607 Reviewed-by: David Benjamin <davidben@google.com> Presubmit-BoringSSL-Verified: boringssl-scoped@luci-project-accounts.iam.gserviceaccount.com <boringssl-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/rust/bssl-tls/src/connection/lifecycle.rs b/rust/bssl-tls/src/connection/lifecycle.rs index 42aef37..658cb76 100644 --- a/rust/bssl-tls/src/connection/lifecycle.rs +++ b/rust/bssl-tls/src/connection/lifecycle.rs
@@ -90,14 +90,7 @@ /// Access handshake-related options if a handshake is completed and /// the connection is initialised. pub fn established<'a>(&'a mut self) -> Option<EstablishedTlsConnection<'a, R, M>> { - let session = unsafe { - // Safety: the validity of the handle `self.0` is witnessed by `self`. - bssl_sys::SSL_get_session(self.ptr()) - }; - if session.is_null() { - return None; - } - Some(EstablishedTlsConnection(self)) + (!self.is_in_handshake()).then_some(EstablishedTlsConnection(self)) } }