Merge pull request #81 from amousset/openssl-0.8

feat(transport-smtp): Use rust-openssl 0.8
This commit is contained in:
Alexis Mousset
2016-09-01 00:23:50 +02:00
committed by GitHub
5 changed files with 12 additions and 19 deletions

View File

@@ -16,7 +16,7 @@ bufstream = "0.1"
email = "0.0"
log = "0.3"
mime = "0.2"
openssl = "0.7"
openssl = { version = "0.8", features = ["tlsv1_2"] }
rustc-serialize = "0.3"
rust-crypto = "0.2"
time = "0.1"

View File

@@ -66,7 +66,7 @@ impl<S: Write + Read> Client<S> {
}
}
impl<S: Connector + Write + Read + Debug + Clone> Client<S> {
impl<S: Connector + Write + Read + Debug> Client<S> {
/// Closes the SMTP transaction if possible
pub fn close(&mut self) {
let _ = self.quit();

View File

@@ -24,7 +24,7 @@ impl Connector for NetworkStream {
match ssl_context {
Some(context) => {
match SslStream::connect_generic(context, tcp_stream) {
match SslStream::connect(context, tcp_stream) {
Ok(stream) => Ok(NetworkStream::Ssl(stream)),
Err(err) => Err(io::Error::new(ErrorKind::Other, err)),
}
@@ -34,16 +34,19 @@ impl Connector for NetworkStream {
}
fn upgrade_tls(&mut self, ssl_context: &SslContext) -> io::Result<()> {
*self = match self.clone() {
NetworkStream::Plain(stream) => {
match SslStream::connect_generic(ssl_context, stream) {
*self = match *self {
NetworkStream::Plain(ref mut stream) => {
match SslStream::connect(ssl_context, stream.try_clone().unwrap()) {
Ok(ssl_stream) => NetworkStream::Ssl(ssl_stream),
Err(err) => return Err(io::Error::new(ErrorKind::Other, err)),
}
}
NetworkStream::Ssl(stream) => NetworkStream::Ssl(stream),
NetworkStream::Ssl(_) => return Ok(())
};
Ok(())
}
fn is_encrypted(&self) -> bool {
@@ -63,16 +66,6 @@ pub enum NetworkStream {
Ssl(SslStream<TcpStream>),
}
impl Clone for NetworkStream {
#[inline]
fn clone(&self) -> NetworkStream {
match *self {
NetworkStream::Plain(ref stream) => NetworkStream::Plain(stream.try_clone().unwrap()),
NetworkStream::Ssl(ref stream) => NetworkStream::Ssl(stream.try_clone().unwrap()),
}
}
}
impl Debug for NetworkStream {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
f.write_str("NetworkStream(_)")

View File

@@ -137,7 +137,7 @@ impl SmtpTransportBuilder {
self
}
/// Require SSL/TLS using STARTTLS
/// Require SSL/TLS using SMTPS
///
/// Incompatible with `encrypt()`
pub fn ssl_wrapper(mut self) -> SmtpTransportBuilder {

View File

@@ -5,7 +5,7 @@ use lettre::transport::EmailTransport;
use lettre::email::EmailBuilder;
#[test]
fn simple_sender() {
fn smtp_transport_simple() {
let mut sender = SmtpTransportBuilder::localhost().unwrap().build();
let email = EmailBuilder::new()
.to("root@localhost")