mirror of
https://github.com/moepman/acertmgr.git
synced 2025-01-01 03:21:49 +01:00
authority.v[12]: skip subsequent account registration
This commit is contained in:
parent
735c986f0d
commit
ba9e206423
@ -22,6 +22,7 @@ class ACMEAuthority(AbstractACMEAuthority):
|
|||||||
# @param key Account key data
|
# @param key Account key data
|
||||||
def __init__(self, config, key):
|
def __init__(self, config, key):
|
||||||
AbstractACMEAuthority.__init__(self, config, key)
|
AbstractACMEAuthority.__init__(self, config, key)
|
||||||
|
self.registered_account = False
|
||||||
self.ca = config['authority']
|
self.ca = config['authority']
|
||||||
self.agreement = config['authority_tos_agreement']
|
self.agreement = config['authority_tos_agreement']
|
||||||
|
|
||||||
@ -64,6 +65,10 @@ class ACMEAuthority(AbstractACMEAuthority):
|
|||||||
# @brief register an account over ACME
|
# @brief register an account over ACME
|
||||||
# @return True if new account was registered, False otherwise
|
# @return True if new account was registered, False otherwise
|
||||||
def register_account(self):
|
def register_account(self):
|
||||||
|
if self.registered_account:
|
||||||
|
# We already have registered with this authority, just return
|
||||||
|
return
|
||||||
|
|
||||||
header = self._prepare_header()
|
header = self._prepare_header()
|
||||||
code, result = self._send_signed(self.ca + "/acme/new-reg", header, {
|
code, result = self._send_signed(self.ca + "/acme/new-reg", header, {
|
||||||
"resource": "new-reg",
|
"resource": "new-reg",
|
||||||
@ -71,9 +76,11 @@ class ACMEAuthority(AbstractACMEAuthority):
|
|||||||
})
|
})
|
||||||
if code == 201:
|
if code == 201:
|
||||||
print("Registered!")
|
print("Registered!")
|
||||||
|
self.registered_account = True
|
||||||
return True
|
return True
|
||||||
elif code == 409:
|
elif code == 409:
|
||||||
print("Already registered!")
|
print("Already registered!")
|
||||||
|
self.registered_account = True
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
raise ValueError("Error registering: {0} {1}".format(code, result))
|
raise ValueError("Error registering: {0} {1}".format(code, result))
|
||||||
|
@ -119,6 +119,10 @@ class ACMEAuthority(AbstractACMEAuthority):
|
|||||||
|
|
||||||
# @brief register an account over ACME
|
# @brief register an account over ACME
|
||||||
def register_account(self):
|
def register_account(self):
|
||||||
|
if self.account_id:
|
||||||
|
# We already have registered with this authority, just return
|
||||||
|
return
|
||||||
|
|
||||||
protected = copy.deepcopy(self.account_protected)
|
protected = copy.deepcopy(self.account_protected)
|
||||||
payload = {
|
payload = {
|
||||||
"termsOfServiceAgreed": self.tos_agreed,
|
"termsOfServiceAgreed": self.tos_agreed,
|
||||||
|
Loading…
Reference in New Issue
Block a user