From b87f57271964ffbab5e4eaf5875c030ef4cbb4af Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Tue, 15 Nov 2022 10:03:10 +0100 Subject: [PATCH] Create constructor for KeyAuthorization --- src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 748ae87..6b35905 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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) @@ -429,9 +429,13 @@ trait Signer { /// /// /// -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