Fill out the context methods
This commit is contained in:
parent
448e8ebbf7
commit
a42d5261f9
4
ffi.rs
4
ffi.rs
|
|
@ -30,7 +30,11 @@ externfn!(fn ERR_get_error() -> c_ulong)
|
||||||
|
|
||||||
externfn!(fn SSL_library_init() -> c_int)
|
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 SSLv23_method() -> *SSL_METHOD)
|
||||||
|
|
||||||
externfn!(fn SSL_CTX_new(method: *SSL_METHOD) -> *SSL_CTX)
|
externfn!(fn SSL_CTX_new(method: *SSL_METHOD) -> *SSL_CTX)
|
||||||
externfn!(fn SSL_CTX_free(ctx: *SSL_CTX))
|
externfn!(fn SSL_CTX_free(ctx: *SSL_CTX))
|
||||||
externfn!(fn SSL_CTX_set_verify(ctx: *SSL_CTX, mode: c_int,
|
externfn!(fn SSL_CTX_set_verify(ctx: *SSL_CTX, mode: c_int,
|
||||||
|
|
|
||||||
12
lib.rs
12
lib.rs
|
|
@ -1,5 +1,3 @@
|
||||||
#[link(name="ssl")];
|
|
||||||
|
|
||||||
use std::rt::io::{Reader, Writer, Stream, Decorator};
|
use std::rt::io::{Reader, Writer, Stream, Decorator};
|
||||||
use std::unstable::atomics::{AtomicBool, INIT_ATOMIC_BOOL, Acquire, Release};
|
use std::unstable::atomics::{AtomicBool, INIT_ATOMIC_BOOL, Acquire, Release};
|
||||||
use std::task;
|
use std::task;
|
||||||
|
|
@ -30,12 +28,18 @@ pub fn init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum SslMethod {
|
pub enum SslMethod {
|
||||||
|
Sslv2,
|
||||||
|
Sslv3,
|
||||||
|
Tlsv1,
|
||||||
Sslv23
|
Sslv23
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SslMethod {
|
impl SslMethod {
|
||||||
unsafe fn to_raw(&self) -> *ffi::SSL_METHOD {
|
unsafe fn to_fn(&self) -> *ffi::SSL_METHOD {
|
||||||
match *self {
|
match *self {
|
||||||
|
Sslv2 => ffi::SSLv2_method(),
|
||||||
|
Sslv3 => ffi::SSLv3_method(),
|
||||||
|
Tlsv1 => ffi::TLSv1_method(),
|
||||||
Sslv23 => ffi::SSLv23_method()
|
Sslv23 => ffi::SSLv23_method()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -55,7 +59,7 @@ impl SslCtx {
|
||||||
pub fn new(method: SslMethod) -> SslCtx {
|
pub fn new(method: SslMethod) -> SslCtx {
|
||||||
init();
|
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());
|
assert!(ctx != ptr::null());
|
||||||
|
|
||||||
SslCtx {
|
SslCtx {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue