From 04841e177332da1920d95a0b9f1a610a072278a2 Mon Sep 17 00:00:00 2001 From: Rodolphe Breard Date: Tue, 1 Sep 2020 20:30:19 +0200 Subject: [PATCH] Fix the account key rollover --- acmed/src/acme_proto/account.rs | 18 ++++++++++++++---- acmed/src/acme_proto/structs/account.rs | 4 ++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/acmed/src/acme_proto/account.rs b/acmed/src/acme_proto/account.rs index 5521dc9..5cff119 100644 --- a/acmed/src/acme_proto/account.rs +++ b/acmed/src/acme_proto/account.rs @@ -104,15 +104,25 @@ pub fn update_account_key( let ep = account.get_endpoint(&endpoint_name)?; let old_account_key = account.get_past_key(&ep.key_hash)?; let old_key = &old_account_key.key; - let rollover_struct = AccountKeyRollover::new(account, &old_key)?; + let account_url = account.get_endpoint(&endpoint_name)?.account_url.clone(); + let rollover_struct = AccountKeyRollover::new(&account_url, &old_key)?; let rollover_struct = serde_json::to_string(&rollover_struct)?; let rollover_payload = encode_jwk_no_nonce( - &old_key, - &old_account_key.signature_algorithm, + &account.current_key.key, + &account.current_key.signature_algorithm, rollover_struct.as_bytes(), &url, )?; - let data_builder = set_data_builder!(account, endpoint_name, rollover_payload.as_bytes()); + let data_builder = |n: &str, url: &str| { + encode_kid( + &old_key, + &old_account_key.signature_algorithm, + &account_url, + rollover_payload.as_bytes(), + url, + n, + ) + }; create_account_if_does_not_exist!( http::post_jose_no_response(endpoint, root_certs, &data_builder, &url), endpoint, diff --git a/acmed/src/acme_proto/structs/account.rs b/acmed/src/acme_proto/structs/account.rs index 0810439..fb8dd3e 100644 --- a/acmed/src/acme_proto/structs/account.rs +++ b/acmed/src/acme_proto/structs/account.rs @@ -56,9 +56,9 @@ pub struct AccountKeyRollover { } impl AccountKeyRollover { - pub fn new(account: &crate::account::Account, old_key: &KeyPair) -> Result { + pub fn new(account_str: &str, old_key: &KeyPair) -> Result { Ok(AccountKeyRollover { - account: account.name.clone(), + account: account_str.to_string(), old_key: old_key.jwk_public_key()?, }) }