session is nullable

This commit is contained in:
Steven Fackler 2017-01-04 21:15:09 -08:00
parent 5d53405597
commit 0b1bfee46d
1 changed files with 9 additions and 2 deletions

View File

@ -1349,8 +1349,15 @@ impl SslRef {
}
/// Returns the SSL session.
pub fn session(&self) -> &SslSessionRef {
unsafe { SslSessionRef::from_ptr(ffi::SSL_get_session(self.as_ptr())) }
pub fn session(&self) -> Option<&SslSessionRef> {
unsafe {
let p = ffi::SSL_get_session(self.as_ptr());
if p.is_null() {
None
} else {
Some(SslSessionRef::from_ptr(p))
}
}
}
}