diff options
author | siddharth <s@ricketyspace.net> | 2021-05-05 20:18:22 -0400 |
---|---|---|
committer | siddharth <s@ricketyspace.net> | 2021-05-05 20:18:22 -0400 |
commit | b6cf3a6839e3480131d2c78d1a672e6839722ade (patch) | |
tree | bb4358fb5aa1432652bfef32f9cdeb64cc0f446e /acmens.py | |
parent | 0dbbe7f7973904a6eef4900a42dd66a04f76948f (diff) |
acmens.py: move `_cmd` out of `sign_csr` and `revoke_crt`
Diffstat (limited to 'acmens.py')
-rw-r--r-- | acmens.py | 31 |
1 files changed, 11 insertions, 20 deletions
@@ -25,6 +25,17 @@ def _b64(b): return base64.urlsafe_b64encode(b).decode().replace("=", "") +def _cmd(cmd_list, stdin=None, cmd_input=None, err_msg="Command Line Error"): + "Runs external commands" + proc = subprocess.Popen( + cmd_list, stdin=stdin, stdout=subprocess.PIPE, stderr=subprocess.PIPE + ) + out, err = proc.communicate(cmd_input) + if proc.returncode != 0: + raise IOError("{0}\n{1}".format(err_msg, err)) + return out + + def sign_csr(ca_url, account_key, csr, email=None, challenge_type="http"): """Use the ACME protocol to get an ssl certificate signed by a certificate authority. @@ -43,16 +54,6 @@ def sign_csr(ca_url, account_key, csr, email=None, challenge_type="http"): """ DIRECTORY = json.loads(urlopen(ca_url + "/directory").read().decode("utf8")) - # helper function - run external commands - def _cmd(cmd_list, stdin=None, cmd_input=None, err_msg="Command Line Error"): - proc = subprocess.Popen( - cmd_list, stdin=stdin, stdout=subprocess.PIPE, stderr=subprocess.PIPE - ) - out, err = proc.communicate(cmd_input) - if proc.returncode != 0: - raise IOError("{0}\n{1}".format(err_msg, err)) - return out - # helper function - make request and automatically parse json response def _do_request(url, data=None, err_msg="Error", depth=0): try: @@ -349,16 +350,6 @@ def revoke_crt(ca_url, account_key, crt): "Shortcut function to go from jwt base64 string to bytes" return base64.urlsafe_b64decode(str(a + ("=" * (len(a) % 4)))) - # helper function - run external commands - def _cmd(cmd_list, stdin=None, cmd_input=None, err_msg="Command Line Error"): - proc = subprocess.Popen( - cmd_list, stdin=stdin, stdout=subprocess.PIPE, stderr=subprocess.PIPE - ) - out, err = proc.communicate(cmd_input) - if proc.returncode != 0: - raise IOError("{0}\n{1}".format(err_msg, err)) - return out - # helper function - make request and automatically parse json response def _do_request(url, data=None, err_msg="Error", depth=0): try: |