mirror of
https://github.com/certbot/certbot.git
synced 2026-07-28 00:35:50 +02:00
Refactored to use json field on Registration.
This commit is contained in:
@@ -302,9 +302,7 @@ class Registration(ResourceBody):
|
||||
email_prefix = 'mailto:'
|
||||
|
||||
@classmethod
|
||||
def from_data(cls, account_public_key=None, kid=None,
|
||||
hmac_key=None, phone=None, email=None,
|
||||
directory=None, **kwargs):
|
||||
def from_data(cls, phone=None, email=None, external_account_binding=None, **kwargs):
|
||||
"""Create registration resource from contact details."""
|
||||
details = list(kwargs.pop('contact', ()))
|
||||
if phone is not None:
|
||||
@@ -313,9 +311,8 @@ class Registration(ResourceBody):
|
||||
details.append(cls.email_prefix + email)
|
||||
kwargs['contact'] = tuple(details)
|
||||
|
||||
if kid is not None and hmac_key is not None:
|
||||
kwargs['external_account_binding'] = ExternalAccountBinding.from_data(account_public_key, kid,
|
||||
hmac_key, directory)
|
||||
if external_account_binding:
|
||||
kwargs['external_account_binding'] = external_account_binding
|
||||
|
||||
return cls(**kwargs)
|
||||
|
||||
|
||||
+10
-6
@@ -196,13 +196,17 @@ def perform_registration(acme, config, tos_cb):
|
||||
if config.eab_kid is None or config.eab_hmac_key is None:
|
||||
raise errors.Error("Server requires external account binding. Please use --eab-kid and --eab-hmac-key.")
|
||||
|
||||
account_public_key = acme.client.net.key.public_key()
|
||||
account_public_key = acme.client.net.key.public_key()
|
||||
eab = messages.ExternalAccountBinding.from_data(account_public_key=account_public_key,
|
||||
kid=config.eab_kid,
|
||||
hmac_key=config.eab_hmac_key,
|
||||
directory=acme.client.directory)
|
||||
else:
|
||||
eab = None
|
||||
|
||||
try:
|
||||
return acme.new_account_and_tos(messages.NewRegistration.from_data(account_public_key=account_public_key,
|
||||
kid=config.eab_kid,
|
||||
hmac_key=config.eab_hmac_key,
|
||||
email=config.email,
|
||||
directory=acme.client.directory),
|
||||
return acme.new_account_and_tos(messages.NewRegistration.from_data(email=config.email,
|
||||
external_account_binding=eab),
|
||||
tos_cb)
|
||||
except messages.Error as e:
|
||||
if e.code == "invalidEmail" or e.code == "invalidContact":
|
||||
|
||||
Reference in New Issue
Block a user