From ba9e20642308410c1aefe8aa9858ba0300fdc707 Mon Sep 17 00:00:00 2001 From: Kishi85 Date: Thu, 28 Mar 2019 09:22:28 +0100 Subject: [PATCH] authority.v[12]: skip subsequent account registration --- acertmgr/authority/v1.py | 7 +++++++ acertmgr/authority/v2.py | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/acertmgr/authority/v1.py b/acertmgr/authority/v1.py index d4861f8..af63604 100644 --- a/acertmgr/authority/v1.py +++ b/acertmgr/authority/v1.py @@ -22,6 +22,7 @@ class ACMEAuthority(AbstractACMEAuthority): # @param key Account key data def __init__(self, config, key): AbstractACMEAuthority.__init__(self, config, key) + self.registered_account = False self.ca = config['authority'] self.agreement = config['authority_tos_agreement'] @@ -64,6 +65,10 @@ class ACMEAuthority(AbstractACMEAuthority): # @brief register an account over ACME # @return True if new account was registered, False otherwise def register_account(self): + if self.registered_account: + # We already have registered with this authority, just return + return + header = self._prepare_header() code, result = self._send_signed(self.ca + "/acme/new-reg", header, { "resource": "new-reg", @@ -71,9 +76,11 @@ class ACMEAuthority(AbstractACMEAuthority): }) if code == 201: print("Registered!") + self.registered_account = True return True elif code == 409: print("Already registered!") + self.registered_account = True return False else: raise ValueError("Error registering: {0} {1}".format(code, result)) diff --git a/acertmgr/authority/v2.py b/acertmgr/authority/v2.py index 590e26d..0445636 100644 --- a/acertmgr/authority/v2.py +++ b/acertmgr/authority/v2.py @@ -119,6 +119,10 @@ class ACMEAuthority(AbstractACMEAuthority): # @brief register an account over ACME def register_account(self): + if self.account_id: + # We already have registered with this authority, just return + return + protected = copy.deepcopy(self.account_protected) payload = { "termsOfServiceAgreed": self.tos_agreed,