From 70f378909879975ee1682dd9fb616062dc08a49a Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 22 Dec 2021 11:58:02 +0100 Subject: [PATCH] Make tokio-rustls dependency optional --- Cargo.toml | 6 ++++-- src/client.rs | 10 +++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5b13847..7b69b50 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,14 +7,16 @@ authors = ["Ritesh Chitlangi "] description = "EPP (Extensible Provisioning Protocol) Client Library for Domain Registration and Management" repository = "https://github.com/masalachai/epp-client" +[features] +default = ["tokio-rustls"] + [dependencies] celes = "2.1" chrono = "0.4" quick-xml = { version = "0.22", features = [ "serialize" ] } -rustls = "0.20" serde = { version = "1.0", features = ["derive"] } tokio = { version = "1.0", features = [ "full" ] } -tokio-rustls = "0.23" +tokio-rustls = { version = "0.23", optional = true } tracing = "0.1.29" webpki-roots = "0.22.1" diff --git a/src/client.rs b/src/client.rs index 1d9d10d..03baa40 100644 --- a/src/client.rs +++ b/src/client.rs @@ -34,14 +34,17 @@ //! ``` use std::convert::TryInto; +use std::io; use std::net::SocketAddr; use std::sync::Arc; -use std::io; use tokio::io::{AsyncRead, AsyncWrite}; use tokio::net::TcpStream; +#[cfg(feature = "tokio-rustls")] use tokio_rustls::client::TlsStream; +#[cfg(feature = "tokio-rustls")] use tokio_rustls::rustls::{ClientConfig, OwnedTrustAnchor, RootCertStore}; +#[cfg(feature = "tokio-rustls")] use tokio_rustls::TlsConnector; use tracing::info; @@ -60,6 +63,7 @@ pub struct EppClient { connection: EppConnection, } +#[cfg(feature = "tokio-rustls")] impl EppClient> { /// Connect to the specified `addr` and `hostname` over TLS /// @@ -94,10 +98,10 @@ impl EppClient> { Some((certs, key)) => { let certs = certs .into_iter() - .map(|cert| rustls::Certificate(cert.0)) + .map(|cert| tokio_rustls::rustls::Certificate(cert.0)) .collect(); builder - .with_single_cert(certs, rustls::PrivateKey(key.0)) + .with_single_cert(certs, tokio_rustls::rustls::PrivateKey(key.0)) .map_err(|e| Error::Other(e.into()))? } None => builder.with_no_client_auth(),