Allow TLS client config to be overridden

See: https://docs.rs/rustls/latest/rustls/struct.ClientConfig.html
This commit is contained in:
Rob Young
2020-05-11 21:30:01 +01:00
committed by Martin Algesten
parent bbfd125025
commit 2e3a75166d
4 changed files with 133 additions and 1 deletions

View File

@@ -165,7 +165,9 @@ pub(crate) fn connect_https(unit: &Unit) -> Result<Stream, Error> {
let sni = webpki::DNSNameRef::try_from_ascii_str(hostname)
.map_err(|err| Error::DnsFailed(err.to_string()))?;
let sess = rustls::ClientSession::new(&*TLS_CONF, sni);
let tls_conf: &Arc<rustls::ClientConfig> =
unit.tls_config.as_ref().map(|c| &c.0).unwrap_or(&*TLS_CONF);
let sess = rustls::ClientSession::new(&tls_conf, sni);
let sock = connect_host(unit, hostname, port)?;