From: Fredrik Tolf Date: Sun, 23 Jan 2022 19:12:18 +0000 (+0100) Subject: acmecert: Handle older versions of the JSON library. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=1995d63b8936ebbd651c5fdd895b14831c7bc2f2;p=utils.git acmecert: Handle older versions of the JSON library. --- diff --git a/acmecert b/acmecert index 56b1a58..c8c05ff 100755 --- 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):