diff options
| author | Steven Fackler <[email protected]> | 2013-10-12 21:48:08 -0700 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2013-10-12 21:48:08 -0700 |
| commit | 8e2d5242a3f498e3c75a3e45e7fe2255ac96298f (patch) | |
| tree | cb2dcb051e9e8955c43cef5bbe08bd7881ed9775 /src/ssl/lib.rs | |
| parent | Semi-fix EOF (diff) | |
| download | rust-openssl-8e2d5242a3f498e3c75a3e45e7fe2255ac96298f.tar.xz rust-openssl-8e2d5242a3f498e3c75a3e45e7fe2255ac96298f.zip | |
Start of cert verification
Diffstat (limited to 'src/ssl/lib.rs')
| -rw-r--r-- | src/ssl/lib.rs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/ssl/lib.rs b/src/ssl/lib.rs index 6d08e168..faf9e651 100644 --- a/src/ssl/lib.rs +++ b/src/ssl/lib.rs @@ -22,7 +22,6 @@ pub fn init() { } ffi::SSL_library_init(); - ffi::SSL_load_error_strings(); FINISHED_INIT.store(true, Release); } } @@ -60,6 +59,15 @@ impl SslCtx { ctx: ctx } } + + pub fn set_verify(&mut self, mode: SslVerifyMode) { + unsafe { ffi::SSL_CTX_set_verify(self.ctx, mode as c_int, None) } + } +} + +pub enum SslVerifyMode { + SslVerifyNone = ffi::SSL_VERIFY_NONE, + SslVerifyPeer = ffi::SSL_VERIFY_PEER } #[deriving(Eq, TotalEq, ToStr)] @@ -186,7 +194,7 @@ pub struct SslStream<S> { } impl<S: Stream> SslStream<S> { - pub fn new(ctx: SslCtx, stream: S) -> SslStream<S> { + pub fn new(ctx: SslCtx, stream: S) -> Result<SslStream<S>, uint> { let ssl = Ssl::new(&ctx); let rbio = MemBio::new(); @@ -205,11 +213,15 @@ impl<S: Stream> SslStream<S> { stream: stream }; - do stream.in_retry_wrapper |ssl| { + let ret = do stream.in_retry_wrapper |ssl| { ssl.ssl.connect() }; - stream + match ret { + Ok(_) => Ok(stream), + // FIXME + Err(_err) => Err(unsafe { ffi::ERR_get_error() as uint }) + } } fn in_retry_wrapper(&mut self, blk: &fn(&mut SslStream<S>) -> int) |