diff --git a/acme/acme/messages.py b/acme/acme/messages.py index 49c18e94e..e5c68dd54 100644 --- a/acme/acme/messages.py +++ b/acme/acme/messages.py @@ -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) diff --git a/certbot/client.py b/certbot/client.py index 26d985662..b538774fd 100644 --- a/certbot/client.py +++ b/certbot/client.py @@ -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":