Skip to content

Commit

Permalink
Merge pull request #435 from markuskobler/master
Browse files Browse the repository at this point in the history
Updates for rust-openssl 0.6.0
  • Loading branch information
seanmonstar committed Apr 6, 2015
2 parents 7d9bab7 + 660a362 commit 2098809
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,14 @@ 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;

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 {}

Expand Down Expand Up @@ -180,12 +172,10 @@ impl HttpListener {
/// Start listening to an address over HTTPS.
pub fn https<To: ToSocketAddrs>(addr: To, cert: &Path, key: &Path) -> io::Result<HttpListener> {
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)))
}
}
Expand Down

0 comments on commit 2098809

Please sign in to comment.