Rename to account_public_key, hmac_key and make some non-optional.

Rename command line argument to --eab-hmac-key.
This commit is contained in:
Robert Kästel
2018-10-23 11:40:57 +02:00
parent 4a9b5143d6
commit 5dc39b66b2
3 changed files with 12 additions and 12 deletions
+7 -7
View File
@@ -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)
+3 -3
View File
@@ -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",
+2 -2
View File
@@ -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: