Skip to main content

Rfc9421Signer

Struct Rfc9421Signer 

Source
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>

Source

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.

Source

pub fn with_components(self, components: Vec<Component>) -> Self

Replaces the full component list.

Source

pub fn with_label(self, label: impl Into<String>) -> Self

Replaces the Signature-Input: label (default "sig1").

Source

pub const fn with_created(self, seconds: i64) -> Self

Sets the created= parameter.

Source

pub const fn with_expires(self, seconds: i64) -> Self

Sets the expires= parameter.

Source

pub fn with_nonce(self, nonce: impl Into<String>) -> Self

Sets the nonce= parameter.

Source

pub fn with_tag(self, tag: impl Into<String>) -> Self

Sets the tag= parameter.

Source

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.

Source

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).

Trait Implementations§

Source§

impl<'a> Debug for Rfc9421Signer<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Rfc9421Signer<'a>

§

impl<'a> RefUnwindSafe for Rfc9421Signer<'a>

§

impl<'a> Send for Rfc9421Signer<'a>

§

impl<'a> Sync for Rfc9421Signer<'a>

§

impl<'a> Unpin for Rfc9421Signer<'a>

§

impl<'a> UnsafeUnpin for Rfc9421Signer<'a>

§

impl<'a> UnwindSafe for Rfc9421Signer<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more