From 6aa91b4357c486f18143369021c7ed5a4b5c69e7 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Mon, 3 Jun 2019 21:05:31 -0400 Subject: sign_csr.py: Update _b64 function. - Convert `b` to `bytes` if it is a `str`. - Convert the base64 encoded `bytes` to `str` before using `replace` for stripping `=`. --- sign_csr.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sign_csr.py b/sign_csr.py index aadb2e9..1e64eac 100644 --- a/sign_csr.py +++ b/sign_csr.py @@ -30,7 +30,10 @@ def sign_csr(pubkey, csr, email=None, file_based=False): def _b64(b): "Shortcut function to go from bytes to jwt base64 string" - return base64.urlsafe_b64encode(b).replace("=", "") + if type(b) is str: + b = b.encode() + + return base64.urlsafe_b64encode(b).decode().replace("=", "") # Step 1: Get account public key sys.stderr.write("Reading pubkey file...\n") -- cgit v1.2.3