add an error message

This commit is contained in:
Michael 2018-08-16 01:34:28 +00:00 committed by Michael Zhang
parent ff03083967
commit b1615fd3dd
No known key found for this signature in database
GPG key ID: A1B65B603268116B

View file

@ -51,11 +51,11 @@ fn main() -> Result<(), Error> {
mac.input(payload.body.as_bytes());
let signature = mac.result().code().into_iter().map(|b| format!("{:02x}", b)).collect::<Vec<_>>().join("");
let auth = payload.headers.get("X-Hub-Signature").ok_or(err_msg("Missing auth header."))?;
let auth = payload.headers.get("X-Hub-Signature").ok_or(err_msg("Missing auth header"))?;
let left = SecStr::from(format!("sha1={}", signature));
let right = SecStr::from(auth.bytes().collect::<Vec<_>>());
assert_eq!(left, right);
assert!(left == right, "HMAC signature didn't match");
println!("{}", payload.body);
Ok(())