Skip to content

Commit 0c4b800

Browse files
authored
Force explicit tls configuration to connect to tls endpoint (#61)
Resolves #60.
1 parent 131f87a commit 0c4b800

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/session/connection.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ pub struct Connector {
176176

177177
impl Connector {
178178
#[cfg(feature = "tls")]
179-
#[allow(dead_code)]
180179
pub fn new() -> Self {
181180
Self { tls: None, timeout: Duration::from_secs(10) }
182181
}
@@ -210,7 +209,7 @@ impl Connector {
210209
if endpoint.tls {
211210
#[cfg(feature = "tls")]
212211
if self.tls.is_none() {
213-
return Err(Error::new(ErrorKind::Unsupported, "tls not supported"));
212+
return Err(Error::new(ErrorKind::Unsupported, "tls not configured"));
214213
}
215214
#[cfg(not(feature = "tls"))]
216215
return Err(Error::new(ErrorKind::Unsupported, "tls not supported"));

src/session/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,10 @@ impl Builder {
130130
return Err(Error::BadArguments(&"connection timeout must not be negative"));
131131
}
132132
#[cfg(feature = "tls")]
133-
let connector = Connector::with_tls(self.tls.unwrap_or_default().into_config()?);
133+
let connector = match self.tls {
134+
Some(options) => Connector::with_tls(options.into_config()?),
135+
None => Connector::new(),
136+
};
134137
#[cfg(not(feature = "tls"))]
135138
let connector = Connector::new();
136139
let (state_sender, state_receiver) = asyncs::sync::watch::channel(SessionState::Disconnected);

0 commit comments

Comments
 (0)