From e5ff431b99cd382e061f68efc267538c35c32bf3 Mon Sep 17 00:00:00 2001 From: Adrien Dorsaz Date: Fri, 12 Jun 2020 22:28:51 +0200 Subject: [PATCH] dns_tiny,deactivate,rollover: simplify a bit space management in regexp See [upstream reference](https://github.com/diafygi/acme-tiny/commit/58752c527c9345d23a771d2a93f729aaa8fe7712). Closes #10 --- acme_dns_tiny.py | 4 ++-- tools/acme_account_deactivate.py | 2 +- tools/acme_account_rollover.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/acme_dns_tiny.py b/acme_dns_tiny.py index cc7a269..cbad341 100644 --- a/acme_dns_tiny.py +++ b/acme_dns_tiny.py @@ -91,7 +91,7 @@ def get_crt(config, log=LOGGER): if common_name is not None: domains.add(common_name.group(1)) subject_alt_names = re.search( - r"X509v3 Subject Alternative Name: (?:critical)?\r?\n +([^\r\n]+)\r?\n", + r"X509v3 Subject Alternative Name: (?:critical)?\s+?([^\r\n]+)\r?\n", csr, re.MULTILINE) if subject_alt_names is not None: for san in subject_alt_names.group(1).split(", "): @@ -123,7 +123,7 @@ def get_crt(config, log=LOGGER): accountkey = _openssl("rsa", ["-in", config["acmednstiny"]["AccountKeyFile"], "-noout", "-text"]) pub_hex, pub_exp = re.search( - r"modulus:\r?\n\s+00:([a-f0-9\:\s]+?)\r?\npublicExponent: ([0-9]+)", + r"modulus:\s+?00:([a-f0-9\:\s]+?)\r?\npublicExponent: ([0-9]+)", accountkey.decode("utf8"), re.MULTILINE).groups() pub_exp = "{0:x}".format(int(pub_exp)) pub_exp = "0{0}".format(pub_exp) if len(pub_exp) % 2 else pub_exp diff --git a/tools/acme_account_deactivate.py b/tools/acme_account_deactivate.py index 4581e13..9acd632 100644 --- a/tools/acme_account_deactivate.py +++ b/tools/acme_account_deactivate.py @@ -79,7 +79,7 @@ def account_deactivate(accountkeypath, acme_directory, log=LOGGER): log.info("Get private signature from account key.") accountkey = _openssl("rsa", ["-in", accountkeypath, "-noout", "-text"]) pub_hex, pub_exp = re.search( - r"modulus:\r?\n\s+00:([a-f0-9\:\s]+?)\r?\npublicExponent: ([0-9]+)", + r"modulus:\s+?00:([a-f0-9\:\s]+?)\r?\npublicExponent: ([0-9]+)", accountkey.decode("utf8"), re.MULTILINE).groups() pub_exp = "{0:x}".format(int(pub_exp)) pub_exp = "0{0}".format(pub_exp) if len(pub_exp) % 2 else pub_exp diff --git a/tools/acme_account_rollover.py b/tools/acme_account_rollover.py index a100988..022be29 100644 --- a/tools/acme_account_rollover.py +++ b/tools/acme_account_rollover.py @@ -37,7 +37,7 @@ def account_rollover(old_accountkeypath, new_accountkeypath, acme_directory, log """Read the account key to get the signature to authenticate with the ACME server.""" accountkey = _openssl("rsa", ["-in", accountkeypath, "-noout", "-text"]) pub_hex, pub_exp = re.search( - r"modulus:\r?\n\s+00:([a-f0-9\:\s]+?)\r?\npublicExponent: ([0-9]+)", + r"modulus:\s+?00:([a-f0-9\:\s]+?)\r?\npublicExponent: ([0-9]+)", accountkey.decode("utf8"), re.MULTILINE).groups() pub_exp = "{0:x}".format(int(pub_exp)) pub_exp = "0{0}".format(pub_exp) if len(pub_exp) % 2 else pub_exp -- GitLab