summaryrefslogtreecommitdiffstats
path: root/acmens.py
diff options
context:
space:
mode:
authorsiddharth <s@ricketyspace.net>2021-05-02 22:34:46 -0400
committersiddharth <s@ricketyspace.net>2021-05-02 22:34:46 -0400
commit0dbbe7f7973904a6eef4900a42dd66a04f76948f (patch)
treeff2f0f153fc83da97c17bf8b1479782a1e5c13e5 /acmens.py
parentae508704925754cd6d325f7181fc759f5d4606d4 (diff)
acmens.py: move `_b64` out of `sign_csr` and `revoke_crt`
Diffstat (limited to 'acmens.py')
-rw-r--r--acmens.py24
1 files changed, 9 insertions, 15 deletions
diff --git a/acmens.py b/acmens.py
index bf1e14f..0529c7d 100644
--- a/acmens.py
+++ b/acmens.py
@@ -12,11 +12,19 @@ from urllib.request import urlopen
from urllib.error import HTTPError
-__version__ = "0.1.4-dev"
+__version__ = "0.1.4-dev0"
CA_PRD = "https://acme-v02.api.letsencrypt.org"
CA_STG = "https://acme-staging-v02.api.letsencrypt.org"
+
+def _b64(b):
+ "Convert bytes to JWT base64 string"
+ if type(b) is str:
+ b = b.encode()
+ return base64.urlsafe_b64encode(b).decode().replace("=", "")
+
+
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.
@@ -35,13 +43,6 @@ def sign_csr(ca_url, account_key, csr, email=None, challenge_type="http"):
"""
DIRECTORY = json.loads(urlopen(ca_url + "/directory").read().decode("utf8"))
- def _b64(b):
- "Shortcut function to go from bytes to jwt base64 string"
- if type(b) is str:
- b = b.encode()
-
- return base64.urlsafe_b64encode(b).decode().replace("=", "")
-
# helper function - run external commands
def _cmd(cmd_list, stdin=None, cmd_input=None, err_msg="Command Line Error"):
proc = subprocess.Popen(
@@ -344,13 +345,6 @@ def revoke_crt(ca_url, account_key, crt):
"""
DIRECTORY = json.loads(urlopen(ca_url + "/directory").read().decode("utf8"))
- def _b64(b):
- "Shortcut function to go from bytes to jwt base64 string"
- if type(b) is str:
- b = b.encode()
-
- return base64.urlsafe_b64encode(b).decode().replace("=", "")
-
def _a64(a):
"Shortcut function to go from jwt base64 string to bytes"
return base64.urlsafe_b64decode(str(a + ("=" * (len(a) % 4))))