Remove brackets from IPv6 literals before passing to TLS connector (#115)

This commit is contained in:
André Cruz
2020-07-13 10:46:28 +01:00
committed by GitHub
parent 81aab6e79a
commit 74afb82de9

View File

@@ -316,7 +316,7 @@ pub(crate) fn connect_https(unit: &Unit) -> Result<Stream, Error> {
let sock = connect_host(unit, hostname, port)?;
let tls_connector = TlsConnector::new().map_err(|e| Error::TlsError(e))?;
let stream = tls_connector.connect(hostname, sock).map_err(|e| match e {
let stream = tls_connector.connect(&hostname.trim_matches(|c| c == '[' || c == ']'), sock).map_err(|e| match e {
HandshakeError::Failure(err) => Error::TlsError(err),
_ => Error::BadStatusRead,
})?;