Borrowed servername
This commit is contained in:
parent
fcb86b8394
commit
f0cde38929
|
|
@ -980,13 +980,15 @@ impl SslRef {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the server's name for the current connection
|
/// Returns the server's name for the current connection
|
||||||
pub fn servername(&self) -> Option<String> {
|
pub fn servername(&self) -> Option<&str> {
|
||||||
let name = unsafe { ffi::SSL_get_servername(self.as_ptr(), ffi::TLSEXT_NAMETYPE_host_name) };
|
unsafe {
|
||||||
if name == ptr::null() {
|
let name = ffi::SSL_get_servername(self.as_ptr(), ffi::TLSEXT_NAMETYPE_host_name);
|
||||||
return None;
|
if name == ptr::null() {
|
||||||
}
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
unsafe { String::from_utf8(CStr::from_ptr(name as *const _).to_bytes().to_vec()).ok() }
|
Some(str::from_utf8(CStr::from_ptr(name as *const _).to_bytes()).unwrap())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Changes the context corresponding to the current connection.
|
/// Changes the context corresponding to the current connection.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue