aboutsummaryrefslogtreecommitdiff
path: root/openssl/src/ssl
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2015-06-27 19:37:45 -0700
committerSteven Fackler <[email protected]>2015-06-27 19:37:45 -0700
commit9d0acfe6155e1f432a80d0bfa99efbbdf0b07100 (patch)
tree46cbc4d2e61351c593edc39adbfa1ab47124c9a6 /openssl/src/ssl
parentStrip other LD_LIBRARY_PATH reference (diff)
downloadrust-openssl-9d0acfe6155e1f432a80d0bfa99efbbdf0b07100.tar.xz
rust-openssl-9d0acfe6155e1f432a80d0bfa99efbbdf0b07100.zip
Fix set_hostname
It was previously failing to null terminate the hostname string (was anyone actually using this?). Also move the macro expansion to the C shim.
Diffstat (limited to 'openssl/src/ssl')
-rw-r--r--openssl/src/ssl/mod.rs12
1 files changed, 2 insertions, 10 deletions
diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs
index a0f97b17..57635523 100644
--- a/openssl/src/ssl/mod.rs
+++ b/openssl/src/ssl/mod.rs
@@ -655,16 +655,8 @@ impl Ssl {
/// Set the host name to be used with SNI (Server Name Indication).
pub fn set_hostname(&self, hostname: &str) -> Result<(), SslError> {
- let ret = unsafe {
- // This is defined as a macro:
- // #define SSL_set_tlsext_host_name(s,name) \
- // SSL_ctrl(s,SSL_CTRL_SET_TLSEXT_HOSTNAME,TLSEXT_NAMETYPE_host_name,(char *)name)
-
- let hostname = CString::new(hostname.as_bytes()).unwrap();
- ffi::SSL_ctrl(self.ssl, ffi::SSL_CTRL_SET_TLSEXT_HOSTNAME,
- ffi::TLSEXT_NAMETYPE_host_name,
- hostname.as_ptr() as *mut c_void)
- };
+ let cstr = CString::new(hostname).unwrap();
+ let ret = unsafe { ffi::SSL_set_tlsext_host_name(self.ssl, cstr.as_ptr()) };
// For this case, 0 indicates failure.
if ret == 0 {