Skip to content

Commit

Permalink
Create constructor for KeyAuthorization
Browse files Browse the repository at this point in the history
  • Loading branch information
djc committed Nov 15, 2022
1 parent f34971b commit b87f572
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl Order {
/// Signs the challenge's token with the account's private key and use the
/// value from [`KeyAuthorization::as_str()`] as the challenge response.
pub fn key_authorization(&self, challenge: &Challenge) -> KeyAuthorization {
KeyAuthorization(format!("{}.{}", challenge.token, &self.account.key.thumb))
KeyAuthorization::new(challenge, &self.account.key)
}

/// Request a certificate from the given Certificate Signing Request (CSR)
Expand Down Expand Up @@ -429,9 +429,13 @@ trait Signer {
/// <https://datatracker.ietf.org/doc/html/rfc8555#section-8.1>
///
/// <https://datatracker.ietf.org/doc/html/rfc8737#section-3>
pub struct KeyAuthorization(pub(crate) String);
pub struct KeyAuthorization(String);

impl KeyAuthorization {
fn new(challenge: &Challenge, key: &Key) -> Self {
Self(format!("{}.{}", challenge.token, &key.thumb))
}

/// Get the key authorization value
pub fn as_str(&self) -> &str {
&self.0
Expand Down

0 comments on commit b87f572

Please sign in to comment.