websocket: Replace futures-rustls with async-tls. (#1298)

This commit is contained in:
Toralf Wittner 2019-11-08 10:46:34 +01:00 committed by GitHub
parent c1226b203a
commit cb74580e35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 11 deletions

View File

@ -10,16 +10,18 @@ keywords = ["peer-to-peer", "libp2p", "networking"]
categories = ["network-programming", "asynchronous"] categories = ["network-programming", "asynchronous"]
[dependencies] [dependencies]
async-tls = "0.5"
bytes = "0.4.12" bytes = "0.4.12"
either = "1.5.3" either = "1.5.3"
futures-preview = "0.3.0-alpha.18" futures-preview = "0.3.0-alpha.18"
#futures-rustls = "0.12.0-alpha" # TODO: https://github.com/quininer/tokio-rustls/issues/51
libp2p-core = { version = "0.13.0", path = "../../core" } libp2p-core = { version = "0.13.0", path = "../../core" }
log = "0.4.8" log = "0.4.8"
rustls = "0.16"
rw-stream-sink = { version = "0.1.1", path = "../../misc/rw-stream-sink" } rw-stream-sink = { version = "0.1.1", path = "../../misc/rw-stream-sink" }
soketto = { git = "https://github.com/paritytech/soketto.git", branch = "develop", features = ["deflate"] } soketto = { git = "https://github.com/paritytech/soketto.git", branch = "develop", features = ["deflate"] }
url = "2.1.0" url = "2.1"
webpki-roots = "0.18.0" webpki = "0.21"
webpki-roots = "0.18"
[dev-dependencies] [dev-dependencies]
libp2p-tcp = { version = "0.13.0", path = "../tcp" } libp2p-tcp = { version = "0.13.0", path = "../tcp" }

View File

@ -18,11 +18,11 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
use async_tls::{client, server};
use bytes::BytesMut; use bytes::BytesMut;
use crate::{error::Error, tls}; use crate::{error::Error, tls};
use either::Either; use either::Either;
use futures::{prelude::*, ready}; use futures::{prelude::*, ready};
use futures_rustls::{client, server, webpki};
use libp2p_core::{ use libp2p_core::{
Transport, Transport,
either::EitherOutput, either::EitherOutput,
@ -301,7 +301,12 @@ where
if use_tls { // begin TLS session if use_tls { // begin TLS session
let dns_name = dns_name.expect("for use_tls we have checked that dns_name is some"); let dns_name = dns_name.expect("for use_tls we have checked that dns_name is some");
trace!("starting TLS handshake with {}", address); trace!("starting TLS handshake with {}", address);
let stream = self.tls_config.client.connect(dns_name.as_ref(), stream) let stream = self.tls_config.client.connect(&dns_name, stream)
.map_err(|e| {
// We should never enter here as we passed a `DNSNameRef` to `connect`.
debug!("invalid domain name: {:?}", dns_name);
Error::Tls(e.into())
})?
.map_err(|e| { .map_err(|e| {
debug!("TLS handshake with {} failed: {}", address, e); debug!("TLS handshake with {} failed: {}", address, e);
Error::Tls(tls::Error::from(e)) Error::Tls(tls::Error::from(e))

View File

@ -18,13 +18,8 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
use async_tls::{TlsConnector, TlsAcceptor};
use std::{fmt, io, sync::Arc}; use std::{fmt, io, sync::Arc};
use futures_rustls::{
TlsConnector,
TlsAcceptor,
rustls,
webpki
};
/// TLS configuration. /// TLS configuration.
#[derive(Clone)] #[derive(Clone)]