From 660a362b68ef5671a951f2c4d66093621d0e3fd3 Mon Sep 17 00:00:00 2001 From: Markus Kobler Date: Mon, 6 Apr 2015 16:04:19 +0100 Subject: [PATCH] chore(net): Upgrading to latest rust openssl 0.6.0 --- src/net.rs | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/net.rs b/src/net.rs index 216f41d38d..0b6f9d8da5 100644 --- a/src/net.rs +++ b/src/net.rs @@ -7,8 +7,7 @@ use std::mem; use std::path::Path; use std::sync::Arc; -use openssl::ssl::{Ssl, SslStream, SslContext}; -use openssl::ssl::SslVerifyMode::SslVerifyNone; +use openssl::ssl::{Ssl, SslStream, SslContext, SSL_VERIFY_NONE}; use openssl::ssl::SslMethod::Sslv23; use openssl::ssl::error::{SslError, StreamError, OpenSslErrors, SslSessionClosed}; use openssl::x509::X509FileType; @@ -16,13 +15,6 @@ use openssl::x509::X509FileType; use typeable::Typeable; use {traitobject}; -macro_rules! try_some { - ($expr:expr) => (match $expr { - Some(val) => { return Err(val); }, - _ => {} - }) -} - /// The write-status indicating headers have not been written. pub enum Fresh {} @@ -180,12 +172,10 @@ impl HttpListener { /// Start listening to an address over HTTPS. pub fn https(addr: To, cert: &Path, key: &Path) -> io::Result { let mut ssl_context = try!(SslContext::new(Sslv23).map_err(lift_ssl_error)); - try_some!(ssl_context.set_cipher_list("DEFAULT").map(lift_ssl_error)); - try_some!(ssl_context.set_certificate_file( - cert, X509FileType::PEM).map(lift_ssl_error)); - try_some!(ssl_context.set_private_key_file( - key, X509FileType::PEM).map(lift_ssl_error)); - ssl_context.set_verify(SslVerifyNone, None); + try!(ssl_context.set_cipher_list("DEFAULT").map_err(lift_ssl_error)); + try!(ssl_context.set_certificate_file(cert, X509FileType::PEM).map_err(lift_ssl_error)); + try!(ssl_context.set_private_key_file(key, X509FileType::PEM).map_err(lift_ssl_error)); + ssl_context.set_verify(SSL_VERIFY_NONE, None); Ok(HttpListener::Https(try!(TcpListener::bind(addr)), Arc::new(ssl_context))) } }