Loading src/ffi.rs +6 −0 Original line number Diff line number Diff line Loading @@ -272,6 +272,10 @@ extern "C" { pub fn ERR_get_error() -> c_ulong; pub fn ERR_lib_error_string(err: c_ulong) -> *const c_char; pub fn ERR_func_error_string(err: c_ulong) -> *const c_char; pub fn ERR_reason_error_string(err: c_ulong) -> *const c_char; pub fn EVP_md5() -> *const EVP_MD; pub fn EVP_ripemd160() -> *const EVP_MD; pub fn EVP_sha1() -> *const EVP_MD; Loading Loading @@ -345,6 +349,8 @@ extern "C" { pub fn SSL_library_init() -> c_int; pub fn SSL_load_error_strings(); #[cfg(feature = "sslv2")] pub fn SSLv2_method() -> *const SSL_METHOD; pub fn SSLv3_method() -> *const SSL_METHOD; Loading src/ssl/error.rs +10 −9 Original line number Diff line number Diff line use libc::c_ulong; use std::io::IoError; use std::c_str::CString; use ffi; Loading @@ -20,24 +21,24 @@ pub enum OpensslError { /// An unknown error UnknownError { /// The library reporting the error library: u8, library: CString, /// The function reporting the error function: u16, function: CString, /// The reason for the error reason: u16 reason: CString } } fn get_lib(err: c_ulong) -> u8 { ((err >> 24) & 0xff) as u8 fn get_lib(err: c_ulong) -> CString { unsafe { CString::new(ffi::ERR_lib_error_string(err), false) } } fn get_func(err: c_ulong) -> u16 { ((err >> 12) & 0xfff) as u16 fn get_func(err: c_ulong) -> CString { unsafe { CString::new(ffi::ERR_func_error_string(err), false) } } fn get_reason(err: c_ulong) -> u16 { (err & 0xfff) as u16 fn get_reason(err: c_ulong) -> CString { unsafe { CString::new(ffi::ERR_reason_error_string(err), false) } } impl SslError { Loading src/ssl/mod.rs +1 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ fn init() { unsafe { INIT.doit(|| { ffi::SSL_library_init(); ffi::SSL_load_error_strings(); // maybe add err_load_crypto_strings? let verify_idx = ffi::SSL_CTX_get_ex_new_index(0, ptr::null(), None, None, None); assert!(verify_idx >= 0); Loading Loading
src/ffi.rs +6 −0 Original line number Diff line number Diff line Loading @@ -272,6 +272,10 @@ extern "C" { pub fn ERR_get_error() -> c_ulong; pub fn ERR_lib_error_string(err: c_ulong) -> *const c_char; pub fn ERR_func_error_string(err: c_ulong) -> *const c_char; pub fn ERR_reason_error_string(err: c_ulong) -> *const c_char; pub fn EVP_md5() -> *const EVP_MD; pub fn EVP_ripemd160() -> *const EVP_MD; pub fn EVP_sha1() -> *const EVP_MD; Loading Loading @@ -345,6 +349,8 @@ extern "C" { pub fn SSL_library_init() -> c_int; pub fn SSL_load_error_strings(); #[cfg(feature = "sslv2")] pub fn SSLv2_method() -> *const SSL_METHOD; pub fn SSLv3_method() -> *const SSL_METHOD; Loading
src/ssl/error.rs +10 −9 Original line number Diff line number Diff line use libc::c_ulong; use std::io::IoError; use std::c_str::CString; use ffi; Loading @@ -20,24 +21,24 @@ pub enum OpensslError { /// An unknown error UnknownError { /// The library reporting the error library: u8, library: CString, /// The function reporting the error function: u16, function: CString, /// The reason for the error reason: u16 reason: CString } } fn get_lib(err: c_ulong) -> u8 { ((err >> 24) & 0xff) as u8 fn get_lib(err: c_ulong) -> CString { unsafe { CString::new(ffi::ERR_lib_error_string(err), false) } } fn get_func(err: c_ulong) -> u16 { ((err >> 12) & 0xfff) as u16 fn get_func(err: c_ulong) -> CString { unsafe { CString::new(ffi::ERR_func_error_string(err), false) } } fn get_reason(err: c_ulong) -> u16 { (err & 0xfff) as u16 fn get_reason(err: c_ulong) -> CString { unsafe { CString::new(ffi::ERR_reason_error_string(err), false) } } impl SslError { Loading
src/ssl/mod.rs +1 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ fn init() { unsafe { INIT.doit(|| { ffi::SSL_library_init(); ffi::SSL_load_error_strings(); // maybe add err_load_crypto_strings? let verify_idx = ffi::SSL_CTX_get_ex_new_index(0, ptr::null(), None, None, None); assert!(verify_idx >= 0); Loading