pub struct Rfc9421Signer<'a> { /* private fields */ }Expand description
A request signer that produces RFC 9421 Signature-Input: and
Signature: headers.
Implementations§
Source§impl<'a> Rfc9421Signer<'a>
impl<'a> Rfc9421Signer<'a>
Sourcepub fn new(key: &'a SigningKey, key_id: &'a str) -> Self
pub fn new(key: &'a SigningKey, key_id: &'a str) -> Self
Creates a signer with the DEFAULT_COMPONENTS layout, label
"sig1", and alg= emitted for compatibility.
§Panics
Panics if any entry in DEFAULT_COMPONENTS fails to parse as
a valid identifier. The default list is a compile-time constant,
so this is unreachable at runtime.
Sourcepub fn with_components(self, components: Vec<Component>) -> Self
pub fn with_components(self, components: Vec<Component>) -> Self
Replaces the full component list.
Sourcepub fn with_label(self, label: impl Into<String>) -> Self
pub fn with_label(self, label: impl Into<String>) -> Self
Replaces the Signature-Input: label (default "sig1").
Sourcepub const fn with_created(self, seconds: i64) -> Self
pub const fn with_created(self, seconds: i64) -> Self
Sets the created= parameter.
Sourcepub const fn with_expires(self, seconds: i64) -> Self
pub const fn with_expires(self, seconds: i64) -> Self
Sets the expires= parameter.
Sourcepub fn with_nonce(self, nonce: impl Into<String>) -> Self
pub fn with_nonce(self, nonce: impl Into<String>) -> Self
Sets the nonce= parameter.
Sourcepub const fn emit_alg(self, emit: bool) -> Self
pub const fn emit_alg(self, emit: bool) -> Self
Controls whether the alg= parameter is emitted. Defaults to
true; set to false to match RFC 9421 §3.3.7’s stated
preference for relying on out-of-band key agreement instead.
Sourcepub fn sign<B>(&self, req: &mut Request<B>) -> Result<(), Error>
pub fn sign<B>(&self, req: &mut Request<B>) -> Result<(), Error>
Signs req and inserts Signature-Input: and Signature: headers.
§Errors
Returns Error::RequiredHeaderAbsent if the request is missing
any referenced header, Error::Crypto if the signing primitive
fails, and Error::InvalidHeader if the resulting header value
cannot be converted to an http::HeaderValue (extremely rare,
only if the key id contains non-ASCII bytes).