Fix crash on no certificate provided

This commit is contained in:
Emi Tatsuo 2020-12-03 10:47:33 -05:00
parent d8d15d8f72
commit cb9b3ea167
Signed by: Emi
GPG key ID: 68FAB2E2E6DFC98B

View file

@ -57,8 +57,11 @@ impl Request {
)
.context("Request URI is invalid")?
.into_owned(),
headers.get("TLS_CLIENT_HASH").map(hash_decode)
.ok_or(anyhow!("Received malformed TLS client hash from upstream. Expected 256 bit hex or b64 encoded"))?,
match headers.get("TLS_CLIENT_HASH").map(hash_decode) {
Some(maybe_hash @ Some(_)) => maybe_hash,
Some(None) => bail!("Received malformed TLS client hash from upstream. Expected 256 bit hex or b64 encoded"),
None => None,
},
headers.get("SCRIPT_PATH")
.or_else(|| headers.get("SCRIPT_NAME"))
.cloned()