Skip to content

Commit

Permalink
feat(bindings): Add API to check for resumption (#4552)
Browse files Browse the repository at this point in the history
  • Loading branch information
goatgoose authored May 16, 2024
1 parent 885b607 commit 89ae410
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
5 changes: 5 additions & 0 deletions bindings/rust/s2n-tls/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 4 additions & 10 deletions bindings/rust/s2n-tls/src/testing/resumption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)?;
Expand Down Expand Up @@ -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)?;

Expand Down Expand Up @@ -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(())
Expand Down

0 comments on commit 89ae410

Please sign in to comment.