acmecert: Handle older versions of the JSON library.
authorFredrik Tolf <fredrik@dolda2000.com>
Sun, 23 Jan 2022 19:12:18 +0000 (20:12 +0100)
committerFredrik Tolf <fredrik@dolda2000.com>
Sun, 23 Jan 2022 19:12:18 +0000 (20:12 +0100)
acmecert

index 56b1a58..c8c05ff 100755 (executable)
--- a/acmecert
+++ b/acmecert
@@ -354,7 +354,7 @@ class problem(msgerror):
 
     @classmethod
     def read(cls, err, **kw):
-        self = cls(err.code, json.load(err), **kw)
+        self = cls(err.code, json.loads(err.read().decode("utf-8")), **kw)
         return self
 
 def jreq(url, data, auth):
@@ -369,7 +369,7 @@ def jreq(url, data, auth):
     enc = {"protected": authdata, "payload": data, "signature": seal}
     try:
         with req(url, data=enc) as resp:
-            return json.load(resp), resp.headers
+            return json.loads(resp.read().decode("utf-8")), resp.headers
     except urllib.error.HTTPError as exc:
         if exc.headers["Content-Type"] == "application/problem+json":
             raise problem.read(exc, url=url)
@@ -432,7 +432,7 @@ def directory():
     global _directory
     if _directory is None:
         with req(service) as resp:
-            _directory = json.load(resp)
+            _directory = json.loads(resp.read().decode("utf-8"))
     return _directory
 
 def register(keysize=4096):