aboutsummaryrefslogtreecommitdiff
path: root/openssl/src
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2017-01-04 21:07:51 -0800
committerSteven Fackler <[email protected]>2017-01-04 21:11:06 -0800
commit5d53405597f2e8dc3a6543e8c4a56705b0ecd47a (patch)
treee3e45f483948432b9c69b969de037d69f673688a /openssl/src
parentTypes and accessor for SslSession (diff)
downloadrust-openssl-5d53405597f2e8dc3a6543e8c4a56705b0ecd47a.tar.xz
rust-openssl-5d53405597f2e8dc3a6543e8c4a56705b0ecd47a.zip
Provide access to the session ID
Diffstat (limited to 'openssl/src')
-rw-r--r--openssl/src/ssl/mod.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs
index d1ed55fe..3949210d 100644
--- a/openssl/src/ssl/mod.rs
+++ b/openssl/src/ssl/mod.rs
@@ -1029,6 +1029,19 @@ impl SslCipherRef {
}
}
+type_!(SslSession, SslSessionRef, ffi::SSL_SESSION, ffi::SSL_SESSION_free);
+
+impl SslSessionRef {
+ /// Returns the SSL session ID.
+ pub fn id(&self) -> &[u8] {
+ unsafe {
+ let mut len = 0;
+ let p = ffi::SSL_SESSION_get_id(self.as_ptr(), &mut len);
+ slice::from_raw_parts(p as *const u8, len as usize)
+ }
+ }
+}
+
type_!(Ssl, SslRef, ffi::SSL, ffi::SSL_free);
impl fmt::Debug for SslRef {
@@ -1350,8 +1363,6 @@ impl fmt::Debug for Ssl {
}
}
-type_!(SslSession, SslSessionRef, ffi::SSL_SESSION, ffi::SSL_SESSION_free);
-
impl Ssl {
pub fn new(ctx: &SslContext) -> Result<Ssl, ErrorStack> {
unsafe {