Commit f29f6b4b authored by Adrien Dorsaz's avatar Adrien Dorsaz

replace function comments by Python docstring

parent 64b9c4ca
......@@ -6,12 +6,12 @@ LOGGER = logging.getLogger('acme_dns_tiny')
LOGGER.addHandler(logging.StreamHandler())
def get_crt(config, log=LOGGER):
# helper function base64 encode as defined in acme spec
def _b64(b):
""""Encodes string as base64 as specified in ACME RFC """
return base64.urlsafe_b64encode(b).decode("utf8").rstrip("=")
# helper function to run openssl command
def _openssl(command, options, communicate=None):
"""Run openssl command line and raise IOError on non-zero return."""
openssl = subprocess.Popen(["openssl", command] + options,
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = openssl.communicate(communicate)
......@@ -19,8 +19,8 @@ def get_crt(config, log=LOGGER):
raise IOError("OpenSSL Error: {0}".format(err))
return out
# helper function to send DNS dynamic update messages
def _update_dns(rrset, action):
"""Updates DNS resource by adding or deleting resource."""
algorithm = dns.name.from_text("{0}".format(config["TSIGKeyring"]["Algorithm"].lower()))
dns_update = dns.update.Update(config["DNS"]["zone"], keyring=keyring, keyalgorithm=algorithm)
if action == "add":
......@@ -31,8 +31,8 @@ def get_crt(config, log=LOGGER):
dns_update = None
return resp
# helper function to send signed requests
def _send_signed_request(url, payload):
"""Sends signed requests to ACME server."""
nonlocal jws_nonce
payload64 = _b64(json.dumps(payload).encode("utf8"))
protected = copy.deepcopy(jws_header)
......
......@@ -5,12 +5,12 @@ LOGGER = logging.getLogger("acme_account_deactivate")
LOGGER.addHandler(logging.StreamHandler())
def account_deactivate(accountkeypath, acme_directory, log=LOGGER):
# helper function base64 encode as defined in acme spec
def _b64(b):
""""Encodes string as base64 as specified in ACME RFC """
return base64.urlsafe_b64encode(b).decode("utf8").rstrip("=")
# helper function to run openssl command
def _openssl(command, options, communicate=None):
"""Run openssl command line and raise IOError on non-zero return."""
openssl = subprocess.Popen(["openssl", command] + options,
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = openssl.communicate(communicate)
......@@ -18,8 +18,8 @@ def account_deactivate(accountkeypath, acme_directory, log=LOGGER):
raise IOError("OpenSSL Error: {0}".format(err))
return out
# helper function to send signed requests
def _send_signed_request(url, payload):
"""Sends signed requests to ACME server."""
nonlocal jws_nonce
payload64 = _b64(json.dumps(payload).encode("utf8"))
protected = copy.deepcopy(jws_header)
......
......@@ -5,12 +5,12 @@ LOGGER = logging.getLogger("acme_account_rollover")
LOGGER.addHandler(logging.StreamHandler())
def account_rollover(accountkeypath, new_accountkeypath, acme_directory, log=LOGGER):
# helper function base64 encode as defined in acme spec
def _b64(b):
""""Encodes string as base64 as specified in ACME RFC """
return base64.urlsafe_b64encode(b).decode("utf8").rstrip("=")
# helper function to run openssl command
def _openssl(command, options, communicate=None):
"""Run openssl command line and raise IOError on non-zero return."""
openssl = subprocess.Popen(["openssl", command] + options,
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = openssl.communicate(communicate)
......@@ -18,8 +18,8 @@ def account_rollover(accountkeypath, new_accountkeypath, acme_directory, log=LOG
raise IOError("OpenSSL Error: {0}".format(err))
return out
# helper function to get jws_header from account key path
def _jws_header(accountkeypath):
"""Creates a JWS header according to a specific account key path."""
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]+)",
......@@ -37,8 +37,8 @@ def account_rollover(accountkeypath, new_accountkeypath, acme_directory, log=LOG
}
return jws_header
# helper function to sign request with specified key path
def _sign_request(url, keypath, payload):
"""Signs request with a specific right account key."""
nonlocal jws_nonce
payload64 = _b64(json.dumps(payload).encode("utf8"))
if keypath == accountkeypath:
......@@ -60,8 +60,8 @@ def account_rollover(accountkeypath, new_accountkeypath, acme_directory, log=LOG
}
return signedjws
# helper function make signed requests
def _send_signed_request(url, keypath, payload):
"""Sends signed requests to ACME server."""
nonlocal jws_nonce
jws = _sign_request(url, keypath, payload)
try:
......
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