Skip to content

Commit

Permalink
Merge pull request #148 from Jokler/openssl-upgrade
Browse files Browse the repository at this point in the history
Upgrade native-tls and tokio-tls to 0.2
  • Loading branch information
aatxe authored Sep 17, 2018
2 parents c8aed29 + 0be5cb2 commit 34592c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ encoding = "0.2"
failure = "0.1"
futures = "0.1"
log = "0.4"
native-tls = "0.1"
native-tls = "0.2"
serde = "1.0"
serde_derive = "1.0"
serde_json = { version = "1.0", optional = true }
Expand All @@ -40,7 +40,7 @@ tokio-core = "0.1"
tokio-io = "0.1"
tokio-mockstream = "1.1"
tokio-timer = "0.1"
tokio-tls = "0.1"
tokio-tls = "0.2"
toml = { version = "0.4", optional = true }

[dev-dependencies]
Expand Down
16 changes: 8 additions & 8 deletions src/client/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ use std::io::Read;
use encoding::EncoderTrap;
use encoding::label::encoding_from_whatwg_label;
use futures::{Async, Poll, Future, Sink, StartSend, Stream};
use native_tls::{Certificate, TlsConnector, Pkcs12};
use native_tls::{Certificate, TlsConnector, Identity};
use tokio_codec::Decoder;
use tokio_core::reactor::Handle;
use tokio_core::net::{TcpStream, TcpStreamNew};
use tokio_mockstream::MockStream;
use tokio_tls::{TlsConnectorExt, TlsStream};
use tokio_tls::{self, TlsStream};

use error;
use client::data::Config;
Expand Down Expand Up @@ -129,30 +129,30 @@ impl Connection {
} else if config.use_ssl() {
let domain = format!("{}", config.server()?);
info!("Connecting via SSL to {}.", domain);
let mut builder = TlsConnector::builder()?;
let mut builder = TlsConnector::builder();
if let Some(cert_path) = config.cert_path() {
let mut file = File::open(cert_path)?;
let mut cert_data = vec![];
file.read_to_end(&mut cert_data)?;
let cert = Certificate::from_der(&cert_data)?;
builder.add_root_certificate(cert)?;
builder.add_root_certificate(cert);
info!("Added {} to trusted certificates.", cert_path);
}
if let Some(client_cert_path) = config.client_cert_path() {
let client_cert_pass = config.client_cert_pass();
let mut file = File::open(client_cert_path)?;
let mut client_cert_data = vec![];
file.read_to_end(&mut client_cert_data)?;
let pkcs12_archive = Pkcs12::from_der(&client_cert_data, &client_cert_pass)?;
builder.identity(pkcs12_archive)?;
let pkcs12_archive = Identity::from_pkcs12(&client_cert_data, &client_cert_pass)?;
builder.identity(pkcs12_archive);
info!("Using {} for client certificate authentication.", client_cert_path);
}
let connector = builder.build()?;
let connector: tokio_tls::TlsConnector = builder.build()?.into();
let stream = Box::new(TcpStream::connect(&config.socket_addr()?, handle).map_err(|e| {
let res: error::IrcError = e.into();
res
}).and_then(move |socket| {
connector.connect_async(&domain, socket).map_err(
connector.connect(&domain, socket).map_err(
|e| e.into(),
)
}));
Expand Down

0 comments on commit 34592c3

Please sign in to comment.