From 5dc39b66b25e0e3ea47b1e582b45f8fcf5edb0ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20K=C3=A4stel?= Date: Tue, 23 Oct 2018 11:40:57 +0200 Subject: [PATCH] Rename to account_public_key, hmac_key and make some non-optional. Rename command line argument to --eab-hmac-key. --- acme/acme/messages.py | 14 +++++++------- certbot/cli.py | 6 +++--- certbot/client.py | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/acme/acme/messages.py b/acme/acme/messages.py index 6fded1034..7a6be532c 100644 --- a/acme/acme/messages.py +++ b/acme/acme/messages.py @@ -266,14 +266,14 @@ class ExternalAccountBinding: """ACME External Account Binding""" @classmethod - def from_data(cls, key=None, kid=None, hmac=None): + def from_data(cls, account_public_key, kid, hmac_key): """Create External Account Binding Resource from contact details, kid and hmac.""" - key_json = json.dumps(key.to_partial_json()) - decoded_hmac = jose.b64.b64decode(hmac) + key_json = json.dumps(account_public_key.to_partial_json()) + decoded_hmac_key = jose.b64.b64decode(hmac_key) jws = jose.JWS.sign( payload=key_json, - key=jose.jwk.JWKOct(key=decoded_hmac), + key=jose.jwk.JWKOct(key=decoded_hmac_key), alg=jose.jwa.HS256, kid=kid, include_jwk=False, @@ -305,7 +305,7 @@ class Registration(ResourceBody): email_prefix = 'mailto:' @classmethod - def from_data(cls, key=None, kid=None, hmac=None, phone=None, email=None, **kwargs): + def from_data(cls, account_public_key=None, kid=None, hmac_key=None, phone=None, email=None, **kwargs): """Create registration resource from contact details.""" details = list(kwargs.pop('contact', ())) if phone is not None: @@ -314,8 +314,8 @@ class Registration(ResourceBody): details.append(cls.email_prefix + email) kwargs['contact'] = tuple(details) - if kid is not None and hmac is not None: - kwargs['external_account_binding'] = ExternalAccountBinding.from_data(key, kid, hmac) + if kid is not None and hmac_key is not None: + kwargs['external_account_binding'] = ExternalAccountBinding.from_data(account_public_key, kid, hmac_key) return cls(**kwargs) diff --git a/certbot/cli.py b/certbot/cli.py index 7f8627953..a91d22e00 100644 --- a/certbot/cli.py +++ b/certbot/cli.py @@ -943,9 +943,9 @@ def prepare_and_parse_args(plugins, args, detect_defaults=False): # pylint: dis ) helpful.add( [None, "run", "certonly", "register"], - "--eab-hmac", dest="eab_hmac", - metavar="EAB_HMAC", - help="HMAC for External Account Binding" + "--eab-hmac-key", dest="eab_hmac_key", + metavar="EAB_HMAC_KEY", + help="HMAC key for External Account Binding" ) helpful.add( [None, "run", "certonly", "manage", "delete", "certificates", diff --git a/certbot/client.py b/certbot/client.py index ba69d16e9..05063eb9d 100644 --- a/certbot/client.py +++ b/certbot/client.py @@ -194,9 +194,9 @@ def perform_registration(acme, config, tos_cb): account_public_key = acme.client.net.key.public_key() try: - return acme.new_account_and_tos(messages.NewRegistration.from_data(key=account_public_key, + return acme.new_account_and_tos(messages.NewRegistration.from_data(account_public_key=account_public_key, kid=config.eab_kid, - hmac=config.eab_hmac, + hmac_key=config.eab_hmac_key, email=config.email), tos_cb) except messages.Error as e: