diff options
| author | Kevin Butler <[email protected]> | 2015-02-20 21:04:01 +0000 |
|---|---|---|
| committer | Kevin Butler <[email protected]> | 2015-02-20 21:04:01 +0000 |
| commit | cb0e1688c8aa2e07a917851c829b24e4528d1282 (patch) | |
| tree | 6a9951abe98a6d8eabfbd1a5723ba561014e7491 /openssl/src/ssl | |
| parent | Unique<T> now derefs to *mut T (diff) | |
| download | rust-openssl-cb0e1688c8aa2e07a917851c829b24e4528d1282.tar.xz rust-openssl-cb0e1688c8aa2e07a917851c829b24e4528d1282.zip | |
Update depreciated code
Diffstat (limited to 'openssl/src/ssl')
| -rw-r--r-- | openssl/src/ssl/error.rs | 8 | ||||
| -rw-r--r-- | openssl/src/ssl/mod.rs | 14 | ||||
| -rw-r--r-- | openssl/src/ssl/tests.rs | 4 |
3 files changed, 13 insertions, 13 deletions
diff --git a/openssl/src/ssl/error.rs b/openssl/src/ssl/error.rs index a80c244e..bb2a5557 100644 --- a/openssl/src/ssl/error.rs +++ b/openssl/src/ssl/error.rs @@ -4,7 +4,7 @@ pub use self::OpensslError::*; use libc::c_ulong; use std::error; use std::fmt; -use std::ffi::c_str_to_bytes; +use std::ffi::CStr; use std::old_io::IoError; use ffi; @@ -75,21 +75,21 @@ pub enum OpensslError { fn get_lib(err: c_ulong) -> String { unsafe { - let bytes = c_str_to_bytes(&ffi::ERR_lib_error_string(err)).to_vec(); + let bytes = CStr::from_ptr(ffi::ERR_lib_error_string(err)).to_bytes().to_vec(); String::from_utf8(bytes).unwrap() } } fn get_func(err: c_ulong) -> String { unsafe { - let bytes = c_str_to_bytes(&ffi::ERR_func_error_string(err)).to_vec(); + let bytes = CStr::from_ptr(ffi::ERR_func_error_string(err)).to_bytes().to_vec(); String::from_utf8(bytes).unwrap() } } fn get_reason(err: c_ulong) -> String { unsafe { - let bytes = c_str_to_bytes(&ffi::ERR_reason_error_string(err)).to_vec(); + let bytes = CStr::from_ptr(ffi::ERR_reason_error_string(err)).to_bytes().to_vec(); String::from_utf8(bytes).unwrap() } } diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs index b90386fa..5d3549ff 100644 --- a/openssl/src/ssl/mod.rs +++ b/openssl/src/ssl/mod.rs @@ -1,5 +1,5 @@ use libc::{c_int, c_void, c_long}; -use std::ffi::{CString, c_str_to_bytes}; +use std::ffi::{CStr, CString}; use std::old_io::{IoResult, IoError, EndOfFile, OtherIoError, Stream, Reader, Writer}; use std::mem; use std::fmt; @@ -247,7 +247,7 @@ impl SslContext { pub fn set_CA_file(&mut self, file: &Path) -> Option<SslError> { wrap_ssl_result( unsafe { - let file = CString::from_slice(file.as_vec()); + let file = CString::new(file.as_vec()).unwrap(); ffi::SSL_CTX_load_verify_locations(*self.ctx, file.as_ptr(), ptr::null()) }) } @@ -257,7 +257,7 @@ impl SslContext { file_type: X509FileType) -> Option<SslError> { wrap_ssl_result( unsafe { - let file = CString::from_slice(file.as_vec()); + let file = CString::new(file.as_vec()).unwrap(); ffi::SSL_CTX_use_certificate_file(*self.ctx, file.as_ptr(), file_type as c_int) }) } @@ -267,7 +267,7 @@ impl SslContext { file_type: X509FileType) -> Option<SslError> { wrap_ssl_result( unsafe { - let file = CString::from_slice(file.as_vec()); + let file = CString::new(file.as_vec()).unwrap(); ffi::SSL_CTX_use_PrivateKey_file(*self.ctx, file.as_ptr(), file_type as c_int) }) } @@ -275,7 +275,7 @@ impl SslContext { pub fn set_cipher_list(&mut self, cipher_list: &str) -> Option<SslError> { wrap_ssl_result( unsafe { - let cipher_list = CString::from_slice(cipher_list.as_bytes()); + let cipher_list = CString::new(cipher_list.as_bytes()).unwrap(); ffi::SSL_CTX_set_cipher_list(*self.ctx, cipher_list.as_ptr()) }) } @@ -378,7 +378,7 @@ impl Ssl { // #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::from_slice(hostname.as_bytes()); + 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) @@ -542,7 +542,7 @@ impl<S: Stream> SslStream<S> { let meth = unsafe { ffi::SSL_COMP_get_name(ptr) }; let s = unsafe { - String::from_utf8(c_str_to_bytes(&meth).to_vec()).unwrap() + String::from_utf8(CStr::from_ptr(meth).to_bytes().to_vec()).unwrap() }; Some(s) diff --git a/openssl/src/ssl/tests.rs b/openssl/src/ssl/tests.rs index 73f479bf..4bb3c2ca 100644 --- a/openssl/src/ssl/tests.rs +++ b/openssl/src/ssl/tests.rs @@ -1,7 +1,7 @@ use serialize::hex::FromHex; use std::old_io::net::tcp::TcpStream; use std::old_io::{Writer}; -use std::thread::Thread; +use std::thread; use crypto::hash::Type::{SHA256}; use ssl::SslMethod::Sslv23; @@ -199,7 +199,7 @@ fn test_clone() { let stream = TcpStream::connect("127.0.0.1:15418").unwrap(); let mut stream = SslStream::new(&SslContext::new(Sslv23).unwrap(), stream).unwrap(); let mut stream2 = stream.clone(); - let _t = Thread::spawn(move || { + let _t = thread::spawn(move || { stream2.write_all("GET /\r\n\r\n".as_bytes()).unwrap(); stream2.flush().unwrap(); }); |