aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2013-10-20 22:24:01 -0700
committerSteven Fackler <[email protected]>2013-10-20 22:24:01 -0700
commita42d5261f95a081f8b530fd2c1827082b89f7807 (patch)
tree427852b28240c29200aefcca6cd972a83b80228f
parentMove tests to in-binary and fix link args (diff)
downloadrust-openssl-a42d5261f95a081f8b530fd2c1827082b89f7807.tar.xz
rust-openssl-a42d5261f95a081f8b530fd2c1827082b89f7807.zip
Fill out the context methods
-rw-r--r--ffi.rs4
-rw-r--r--lib.rs12
2 files changed, 12 insertions, 4 deletions
diff --git a/ffi.rs b/ffi.rs
index e63c63a1..57adfaf4 100644
--- a/ffi.rs
+++ b/ffi.rs
@@ -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,
diff --git a/lib.rs b/lib.rs
index fdf827ca..9c5f5845 100644
--- a/lib.rs
+++ b/lib.rs
@@ -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 {