diff --git a/bindings/rust/s2n-tls/src/connection.rs b/bindings/rust/s2n-tls/src/connection.rs index 6ac1dc7a139..442a51f0c39 100644 --- a/bindings/rust/s2n-tls/src/connection.rs +++ b/bindings/rust/s2n-tls/src/connection.rs @@ -1044,6 +1044,11 @@ impl Connection { Ok(()) } } + + /// Determines whether the connection was resumed from an earlier handshake. + pub fn resumed(&self) -> bool { + unsafe { s2n_connection_is_session_resumed(self.connection.as_ptr()) == 1 } + } } struct Context { diff --git a/bindings/rust/s2n-tls/src/testing/resumption.rs b/bindings/rust/s2n-tls/src/testing/resumption.rs index cb1c950a079..1b68a97c6b1 100644 --- a/bindings/rust/s2n-tls/src/testing/resumption.rs +++ b/bindings/rust/s2n-tls/src/testing/resumption.rs @@ -109,10 +109,7 @@ mod tests { let client = pair.client.0.connection(); // Check connection was full handshake and a session ticket was included - assert_eq!( - client.handshake_type()?, - "NEGOTIATED|FULL_HANDSHAKE|TLS12_PERFECT_FORWARD_SECRECY|WITH_SESSION_TICKET" - ); + assert!(!client.resumed()); validate_session_ticket(client)?; // create and configure a client/server connection again @@ -138,7 +135,7 @@ mod tests { let server = pair.server.0.connection(); // Check new connection was resumed - assert_eq!(client.handshake_type()?, "NEGOTIATED"); + assert!(client.resumed()); // validate that a ticket is available validate_session_ticket(client)?; validate_session_ticket(server)?; @@ -195,10 +192,7 @@ mod tests { let client = pair.client.0.connection(); // Check connection was full handshake - assert_eq!( - client.handshake_type()?, - "NEGOTIATED|FULL_HANDSHAKE|MIDDLEBOX_COMPAT" - ); + assert!(!client.resumed()); // validate that a ticket is available validate_session_ticket(client)?; @@ -227,7 +221,7 @@ mod tests { let client = pair.client.0.connection(); // Check new connection was resumed - assert_eq!(client.handshake_type()?, "NEGOTIATED|MIDDLEBOX_COMPAT"); + assert!(client.resumed()); // validate that a ticket is available validate_session_ticket(client)?; Ok(())