Commit e5ff431b authored by Adrien Dorsaz's avatar Adrien Dorsaz

dns_tiny,deactivate,rollover: simplify a bit space management in regexp

See [upstream reference](https://github.com/diafygi/acme-tiny/commit/58752c527c9345d23a771d2a93f729aaa8fe7712).

Closes #10
parent 52eb8e2c
...@@ -91,7 +91,7 @@ def get_crt(config, log=LOGGER): ...@@ -91,7 +91,7 @@ def get_crt(config, log=LOGGER):
if common_name is not None: if common_name is not None:
domains.add(common_name.group(1)) domains.add(common_name.group(1))
subject_alt_names = re.search( 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) csr, re.MULTILINE)
if subject_alt_names is not None: if subject_alt_names is not None:
for san in subject_alt_names.group(1).split(", "): for san in subject_alt_names.group(1).split(", "):
...@@ -123,7 +123,7 @@ def get_crt(config, log=LOGGER): ...@@ -123,7 +123,7 @@ def get_crt(config, log=LOGGER):
accountkey = _openssl("rsa", ["-in", config["acmednstiny"]["AccountKeyFile"], accountkey = _openssl("rsa", ["-in", config["acmednstiny"]["AccountKeyFile"],
"-noout", "-text"]) "-noout", "-text"])
pub_hex, pub_exp = re.search( 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() accountkey.decode("utf8"), re.MULTILINE).groups()
pub_exp = "{0:x}".format(int(pub_exp)) pub_exp = "{0:x}".format(int(pub_exp))
pub_exp = "0{0}".format(pub_exp) if len(pub_exp) % 2 else pub_exp pub_exp = "0{0}".format(pub_exp) if len(pub_exp) % 2 else pub_exp
......
...@@ -79,7 +79,7 @@ def account_deactivate(accountkeypath, acme_directory, log=LOGGER): ...@@ -79,7 +79,7 @@ def account_deactivate(accountkeypath, acme_directory, log=LOGGER):
log.info("Get private signature from account key.") log.info("Get private signature from account key.")
accountkey = _openssl("rsa", ["-in", accountkeypath, "-noout", "-text"]) accountkey = _openssl("rsa", ["-in", accountkeypath, "-noout", "-text"])
pub_hex, pub_exp = re.search( 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() accountkey.decode("utf8"), re.MULTILINE).groups()
pub_exp = "{0:x}".format(int(pub_exp)) pub_exp = "{0:x}".format(int(pub_exp))
pub_exp = "0{0}".format(pub_exp) if len(pub_exp) % 2 else pub_exp pub_exp = "0{0}".format(pub_exp) if len(pub_exp) % 2 else pub_exp
......
...@@ -37,7 +37,7 @@ def account_rollover(old_accountkeypath, new_accountkeypath, acme_directory, log ...@@ -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.""" """Read the account key to get the signature to authenticate with the ACME server."""
accountkey = _openssl("rsa", ["-in", accountkeypath, "-noout", "-text"]) accountkey = _openssl("rsa", ["-in", accountkeypath, "-noout", "-text"])
pub_hex, pub_exp = re.search( 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() accountkey.decode("utf8"), re.MULTILINE).groups()
pub_exp = "{0:x}".format(int(pub_exp)) pub_exp = "{0:x}".format(int(pub_exp))
pub_exp = "0{0}".format(pub_exp) if len(pub_exp) % 2 else pub_exp pub_exp = "0{0}".format(pub_exp) if len(pub_exp) % 2 else pub_exp
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment