diff --git a/letsencrypt/client/acme.py b/letsencrypt/client/acme.py index 3a419c8f1..306ee9171 100755 --- a/letsencrypt/client/acme.py +++ b/letsencrypt/client/acme.py @@ -12,6 +12,10 @@ schemata = {schema: json.load(open("letsencrypt/client/schemata/%s.json" % schem } def acme_object_validate(j): + """Validate a JSON object against the ACME protocol using JSON Schema. + Success will return None; failure to validate will raise a + jsonschema.ValidationError exception describing the reason that the + object could not be validated successfully.""" j = json.loads(j) if not isinstance(j, dict): raise jsonschema.ValidationError("this is not a dictionary object") @@ -21,3 +25,7 @@ def acme_object_validate(j): raise jsonschema.ValidationError("unknown type %s" % j["type"]) jsonschema.validate(j, schemata[j["type"]]) +def pretty(s): + """Return a pretty-printed version of any JSON string (useful when + printing out protocol messages for debugging purposes.""" + return json.dumps(json.loads(s), indent=4)