From cb9b3ea167f2b8a19369434eddd229009289c4e5 Mon Sep 17 00:00:00 2001 From: Emi Tatsuo Date: Thu, 3 Dec 2020 10:47:33 -0500 Subject: [PATCH] Fix crash on no certificate provided --- src/types/request.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/types/request.rs b/src/types/request.rs index f3e3801..d14d052 100644 --- a/src/types/request.rs +++ b/src/types/request.rs @@ -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()