pub fn verify_request(
method: &str,
target_uri: &str,
signature_input: &str,
signature: &str,
content_digest: Option<&str>,
body: &[u8],
headers: &[(&str, &str)],
key: &VerifyingKey<'_>,
) -> Result<(), Error>Expand description
Verify an RFC 9421 signature on an inbound request.
The caller supplies the request as it saw it: the method, the URI it was
made to, the Signature-Input and Signature field values, the
Content-Digest if one was sent, and its header fields. A covered header
field is taken from headers as RFC 9421 §2.1 reads one — every value it
was sent with, trimmed and joined by , — and the derived components a
federation request can be rebuilt from are @method, @target-uri,
@authority, @scheme, @path, @query and @request-target. A
signature covering anything else, or a header that was not sent, is
rejected rather than verified against a base guessed from what is missing.
Fedify covers host and date besides the derived components; a verifier
that read no header fields refused every request it signed this way.
The digest is checked against body, so a signature covering
content-digest binds the body it was sent with.
§Errors
When the signature cannot be read, covers what cannot be rebuilt or was not sent, states an algorithm the key is not, the body does not match its digest, or the signature does not verify.