diff options
| author | Steven Fackler <[email protected]> | 2013-10-20 22:24:01 -0700 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2013-10-20 22:24:01 -0700 |
| commit | a42d5261f95a081f8b530fd2c1827082b89f7807 (patch) | |
| tree | 427852b28240c29200aefcca6cd972a83b80228f | |
| parent | Move tests to in-binary and fix link args (diff) | |
| download | rust-openssl-a42d5261f95a081f8b530fd2c1827082b89f7807.tar.xz rust-openssl-a42d5261f95a081f8b530fd2c1827082b89f7807.zip | |
Fill out the context methods
| -rw-r--r-- | ffi.rs | 4 | ||||
| -rw-r--r-- | lib.rs | 12 |
2 files changed, 12 insertions, 4 deletions
@@ -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, @@ -1,5 +1,3 @@ -#[link(name="ssl")]; - use std::rt::io::{Reader, Writer, Stream, Decorator}; use std::unstable::atomics::{AtomicBool, INIT_ATOMIC_BOOL, Acquire, Release}; use std::task; @@ -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() } } @@ -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 { |