Fix panic on invalid authority
This commit is contained in:
committed by
Martin Algesten
parent
661853b95d
commit
e5fa36f98e
@@ -202,4 +202,12 @@ mod tests {
|
|||||||
);
|
);
|
||||||
assert_eq!("text/html", resp.content_type());
|
assert_eq!("text/html", resp.content_type());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(feature = "tls")]
|
||||||
|
fn connect_https_invalid_name() {
|
||||||
|
let resp = get("https://example.com{REQUEST_URI}/").call();
|
||||||
|
assert_eq!(400, resp.status());
|
||||||
|
assert!(resp.synthetic());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,7 +156,8 @@ pub(crate) fn connect_https(unit: &Unit) -> Result<Stream, Error> {
|
|||||||
let hostname = unit.url.host_str().unwrap();
|
let hostname = unit.url.host_str().unwrap();
|
||||||
let port = unit.url.port().unwrap_or(443);
|
let port = unit.url.port().unwrap_or(443);
|
||||||
|
|
||||||
let sni = webpki::DNSNameRef::try_from_ascii_str(hostname).unwrap();
|
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 sess = rustls::ClientSession::new(&*TLS_CONF, sni);
|
||||||
|
|
||||||
let sock = connect_host(unit, hostname, port)?;
|
let sock = connect_host(unit, hostname, port)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user