Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to the latest openssl #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ url = "1.2"
amq-proto = "0.1.0"

[dependencies.openssl]
version = "0.7.*"
version = "0.10"
optional = true
features = ["tlsv1_1", "tlsv1_2"]

[dev-dependencies]
# clippy = "*"
18 changes: 16 additions & 2 deletions src/amqp_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,22 @@ impl From<amq_proto::Error> for AMQPError {
}

#[cfg(feature = "tls")]
impl From<openssl::ssl::error::SslError> for AMQPError {
fn from(err: openssl::ssl::error::SslError) -> AMQPError {
impl From<openssl::ssl::Error> for AMQPError {
fn from(err: openssl::ssl::Error) -> AMQPError {
AMQPError::Protocol(format!("{}", err))
}
}

#[cfg(feature = "tls")]
impl<T: fmt::Debug> From<openssl::ssl::HandshakeError<T>> for AMQPError {
fn from(err: openssl::ssl::HandshakeError<T>) -> AMQPError {
AMQPError::Protocol(format!("{}", err))
}
}

#[cfg(feature = "tls")]
impl From<openssl::error::ErrorStack> for AMQPError {
fn from(err: openssl::error::ErrorStack) -> AMQPError {
AMQPError::Protocol(format!("{}", err))
}
}
11 changes: 4 additions & 7 deletions src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::io::Write;
use std::cmp;

#[cfg(feature = "tls")]
use openssl::ssl::{SslContext, SslMethod, SslStream};
use openssl::ssl::{SslConnector, SslMethod, SslStream};

use amqp_error::AMQPResult;
use amq_proto::{Frame, FrameType, FramePayload};
Expand All @@ -30,10 +30,7 @@ impl Clone for Connection {
}
#[cfg(feature = "tls")]
AMQPStream::Tls(ref stream) => {
Connection {
socket: AMQPStream::Tls(stream.try_clone().unwrap()),
frame_max_limit: self.frame_max_limit,
}
panic!("SslStream cannot be cloned");
}
}
}
Expand All @@ -43,8 +40,8 @@ impl Connection {
#[cfg(feature = "tls")]
pub fn open_tls(host: &str, port: u16) -> AMQPResult<Connection> {
let socket = try!(TcpStream::connect((host, port)));
let ctx = try!(SslContext::new(SslMethod::Sslv23));
let mut tls_socket = try!(SslStream::connect(&ctx, socket));
let ctx = SslConnector::builder(SslMethod::tls())?.build();
let mut tls_socket = try!(ctx.connect(host, socket));
try!(init_connection(&mut tls_socket));
Ok(Connection {
socket: AMQPStream::Tls(tls_socket),
Expand Down