Skip to content

Commit 89ae410

Browse files
authored
feat(bindings): Add API to check for resumption (#4552)
1 parent 885b607 commit 89ae410

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

bindings/rust/s2n-tls/src/connection.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,11 @@ impl Connection {
10441044
Ok(())
10451045
}
10461046
}
1047+
1048+
/// Determines whether the connection was resumed from an earlier handshake.
1049+
pub fn resumed(&self) -> bool {
1050+
unsafe { s2n_connection_is_session_resumed(self.connection.as_ptr()) == 1 }
1051+
}
10471052
}
10481053

10491054
struct Context {

bindings/rust/s2n-tls/src/testing/resumption.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,7 @@ mod tests {
109109
let client = pair.client.0.connection();
110110

111111
// Check connection was full handshake and a session ticket was included
112-
assert_eq!(
113-
client.handshake_type()?,
114-
"NEGOTIATED|FULL_HANDSHAKE|TLS12_PERFECT_FORWARD_SECRECY|WITH_SESSION_TICKET"
115-
);
112+
assert!(!client.resumed());
116113
validate_session_ticket(client)?;
117114

118115
// create and configure a client/server connection again
@@ -138,7 +135,7 @@ mod tests {
138135
let server = pair.server.0.connection();
139136

140137
// Check new connection was resumed
141-
assert_eq!(client.handshake_type()?, "NEGOTIATED");
138+
assert!(client.resumed());
142139
// validate that a ticket is available
143140
validate_session_ticket(client)?;
144141
validate_session_ticket(server)?;
@@ -195,10 +192,7 @@ mod tests {
195192

196193
let client = pair.client.0.connection();
197194
// Check connection was full handshake
198-
assert_eq!(
199-
client.handshake_type()?,
200-
"NEGOTIATED|FULL_HANDSHAKE|MIDDLEBOX_COMPAT"
201-
);
195+
assert!(!client.resumed());
202196
// validate that a ticket is available
203197
validate_session_ticket(client)?;
204198

@@ -227,7 +221,7 @@ mod tests {
227221

228222
let client = pair.client.0.connection();
229223
// Check new connection was resumed
230-
assert_eq!(client.handshake_type()?, "NEGOTIATED|MIDDLEBOX_COMPAT");
224+
assert!(client.resumed());
231225
// validate that a ticket is available
232226
validate_session_ticket(client)?;
233227
Ok(())

0 commit comments

Comments
 (0)