Loading ffi.rs +4 −0 Original line number Diff line number Diff line Loading @@ -30,7 +30,11 @@ externfn!(fn ERR_get_error() -> c_ulong) externfn!(fn SSL_library_init() -> c_int) externfn!(fn SSLv2_method() -> *SSL_METHOD) externfn!(fn SSLv3_method() -> *SSL_METHOD) externfn!(fn TLSv1_method() -> *SSL_METHOD) externfn!(fn SSLv23_method() -> *SSL_METHOD) externfn!(fn SSL_CTX_new(method: *SSL_METHOD) -> *SSL_CTX) externfn!(fn SSL_CTX_free(ctx: *SSL_CTX)) externfn!(fn SSL_CTX_set_verify(ctx: *SSL_CTX, mode: c_int, Loading lib.rs +8 −4 Original line number Diff line number Diff line #[link(name="ssl")]; use std::rt::io::{Reader, Writer, Stream, Decorator}; use std::unstable::atomics::{AtomicBool, INIT_ATOMIC_BOOL, Acquire, Release}; use std::task; Loading Loading @@ -30,12 +28,18 @@ pub fn init() { } pub enum SslMethod { Sslv2, Sslv3, Tlsv1, Sslv23 } impl SslMethod { unsafe fn to_raw(&self) -> *ffi::SSL_METHOD { unsafe fn to_fn(&self) -> *ffi::SSL_METHOD { match *self { Sslv2 => ffi::SSLv2_method(), Sslv3 => ffi::SSLv3_method(), Tlsv1 => ffi::TLSv1_method(), Sslv23 => ffi::SSLv23_method() } } Loading @@ -55,7 +59,7 @@ impl SslCtx { pub fn new(method: SslMethod) -> SslCtx { init(); let ctx = unsafe { ffi::SSL_CTX_new(method.to_raw()) }; let ctx = unsafe { ffi::SSL_CTX_new(method.to_fn()) }; assert!(ctx != ptr::null()); SslCtx { Loading Loading
ffi.rs +4 −0 Original line number Diff line number Diff line Loading @@ -30,7 +30,11 @@ externfn!(fn ERR_get_error() -> c_ulong) externfn!(fn SSL_library_init() -> c_int) externfn!(fn SSLv2_method() -> *SSL_METHOD) externfn!(fn SSLv3_method() -> *SSL_METHOD) externfn!(fn TLSv1_method() -> *SSL_METHOD) externfn!(fn SSLv23_method() -> *SSL_METHOD) externfn!(fn SSL_CTX_new(method: *SSL_METHOD) -> *SSL_CTX) externfn!(fn SSL_CTX_free(ctx: *SSL_CTX)) externfn!(fn SSL_CTX_set_verify(ctx: *SSL_CTX, mode: c_int, Loading
lib.rs +8 −4 Original line number Diff line number Diff line #[link(name="ssl")]; use std::rt::io::{Reader, Writer, Stream, Decorator}; use std::unstable::atomics::{AtomicBool, INIT_ATOMIC_BOOL, Acquire, Release}; use std::task; Loading Loading @@ -30,12 +28,18 @@ pub fn init() { } pub enum SslMethod { Sslv2, Sslv3, Tlsv1, Sslv23 } impl SslMethod { unsafe fn to_raw(&self) -> *ffi::SSL_METHOD { unsafe fn to_fn(&self) -> *ffi::SSL_METHOD { match *self { Sslv2 => ffi::SSLv2_method(), Sslv3 => ffi::SSLv3_method(), Tlsv1 => ffi::TLSv1_method(), Sslv23 => ffi::SSLv23_method() } } Loading @@ -55,7 +59,7 @@ impl SslCtx { pub fn new(method: SslMethod) -> SslCtx { init(); let ctx = unsafe { ffi::SSL_CTX_new(method.to_raw()) }; let ctx = unsafe { ffi::SSL_CTX_new(method.to_fn()) }; assert!(ctx != ptr::null()); SslCtx { Loading