diff --git a/rustls-libssl/MATRIX.md b/rustls-libssl/MATRIX.md index ae23b7d..1c14d76 100644 --- a/rustls-libssl/MATRIX.md +++ b/rustls-libssl/MATRIX.md @@ -410,7 +410,7 @@ | `SSL_rstate_string_long` | | | | | `SSL_select_next_proto` | | :white_check_mark: | :white_check_mark: | | `SSL_sendfile` | | | | -| `SSL_session_reused` | | :white_check_mark: | :exclamation: [^stub] | +| `SSL_session_reused` | | :white_check_mark: | :white_check_mark: | | `SSL_set0_CA_list` | | | | | `SSL_set0_rbio` | | | :white_check_mark: | | `SSL_set0_security_ex_data` | | | | diff --git a/rustls-libssl/src/entry.rs b/rustls-libssl/src/entry.rs index 5bdfaf2..a49c852 100644 --- a/rustls-libssl/src/entry.rs +++ b/rustls-libssl/src/entry.rs @@ -1633,6 +1633,16 @@ entry! { } } +entry! { + pub fn _SSL_session_reused(ssl: *const SSL) -> c_int { + let ssl = try_clone_arc!(ssl); + ssl.lock() + .ok() + .map(|ssl| ssl.was_session_reused() as c_int) + .unwrap_or_default() + } +} + impl Castable for SSL { type Ownership = OwnershipArc; type RustType = Mutex; @@ -1891,10 +1901,6 @@ entry_stub! { pub fn _SSL_set_session(_ssl: *mut SSL, _session: *mut SSL_SESSION) -> c_int; } -entry_stub! { - pub fn _SSL_session_reused(_ssl: *const SSL) -> c_int; -} - entry_stub! { pub fn _SSL_get1_session(_ssl: *mut SSL) -> *mut SSL_SESSION; } diff --git a/rustls-libssl/src/lib.rs b/rustls-libssl/src/lib.rs index 4eb3c95..fca936a 100644 --- a/rustls-libssl/src/lib.rs +++ b/rustls-libssl/src/lib.rs @@ -16,8 +16,8 @@ use rustls::crypto::aws_lc_rs as provider; use rustls::pki_types::{CertificateDer, ServerName}; use rustls::server::{Accepted, Acceptor}; use rustls::{ - CipherSuite, ClientConfig, ClientConnection, Connection, ProtocolVersion, RootCertStore, - ServerConfig, + CipherSuite, ClientConfig, ClientConnection, Connection, HandshakeKind, ProtocolVersion, + RootCertStore, ServerConfig, }; mod bio; @@ -1216,6 +1216,13 @@ impl Ssl { None => HandshakeState::Before, } } + + fn was_session_reused(&self) -> bool { + match self.conn() { + Some(conn) => conn.handshake_kind() == Some(HandshakeKind::Resumed), + None => false, + } + } } /// This is a reduced-fidelity version of `OSSL_HANDSHAKE_STATE`.