Skip to content

Commit 0db75bd

Browse files
committed
Implement SSL_session_reused
1 parent ce39b95 commit 0db75bd

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

rustls-libssl/MATRIX.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@
410410
| `SSL_rstate_string_long` | | | |
411411
| `SSL_select_next_proto` | | :white_check_mark: | :white_check_mark: |
412412
| `SSL_sendfile` | | | |
413-
| `SSL_session_reused` | | :white_check_mark: | :exclamation: [^stub] |
413+
| `SSL_session_reused` | | :white_check_mark: | :white_check_mark: |
414414
| `SSL_set0_CA_list` | | | |
415415
| `SSL_set0_rbio` | | | :white_check_mark: |
416416
| `SSL_set0_security_ex_data` | | | |

rustls-libssl/src/entry.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,12 @@ entry! {
12441244
}
12451245
}
12461246

1247+
entry! {
1248+
pub fn _SSL_session_reused(ssl: *const SSL) -> c_int {
1249+
try_clone_arc!(ssl).get().was_session_reused() as c_int
1250+
}
1251+
}
1252+
12471253
impl Castable for SSL {
12481254
type Ownership = OwnershipArc;
12491255
type RustType = NotThreadSafe<SSL>;
@@ -1501,10 +1507,6 @@ entry_stub! {
15011507
pub fn _SSL_set_session(_ssl: *mut SSL, _session: *mut SSL_SESSION) -> c_int;
15021508
}
15031509

1504-
entry_stub! {
1505-
pub fn _SSL_session_reused(_ssl: *const SSL) -> c_int;
1506-
}
1507-
15081510
entry_stub! {
15091511
pub fn _SSL_get1_session(_ssl: *mut SSL) -> *mut SSL_SESSION;
15101512
}

rustls-libssl/src/lib.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use rustls::crypto::aws_lc_rs as provider;
1515
use rustls::pki_types::{CertificateDer, ServerName};
1616
use rustls::server::{Accepted, Acceptor};
1717
use rustls::{
18-
CipherSuite, ClientConfig, ClientConnection, Connection, ProtocolVersion, RootCertStore,
19-
ServerConfig, SupportedProtocolVersion,
18+
CipherSuite, ClientConfig, ClientConnection, Connection, HandshakeKind, ProtocolVersion,
19+
RootCertStore, ServerConfig, SupportedProtocolVersion,
2020
};
2121

2222
use not_thread_safe::NotThreadSafe;
@@ -1168,6 +1168,13 @@ impl Ssl {
11681168
None => HandshakeState::Before,
11691169
}
11701170
}
1171+
1172+
fn was_session_reused(&self) -> bool {
1173+
match self.conn() {
1174+
Some(conn) => conn.handshake_kind() == Some(HandshakeKind::Resumed),
1175+
None => false,
1176+
}
1177+
}
11711178
}
11721179

11731180
/// Encode rustls's internal representation in the wire format.

0 commit comments

Comments
 (0)