ACME: improve error handling (#49266)
* Improve error handling: when parse_json_result is False, still return the error message.
* Remove content body from info dict.
* Add changelog.
(cherry picked from commit b842b1b97e
)
This commit is contained in:
parent
832aa98ace
commit
1deb2300a4
2 changed files with 6 additions and 2 deletions
2
changelogs/fragments/49266-acme-error-messages.yml
Normal file
2
changelogs/fragments/49266-acme-error-messages.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- "ACME modules: improve error messages in some cases (include error returned by server)."
|
|
@ -578,7 +578,7 @@ class ACMEAccount(object):
|
|||
try:
|
||||
content = resp.read()
|
||||
except AttributeError:
|
||||
content = info.get('body')
|
||||
content = info.pop('body')
|
||||
|
||||
if content or not parse_json_result:
|
||||
if (parse_json_result and info['content-type'].startswith('application/json')) or 400 <= info['status'] < 600:
|
||||
|
@ -593,6 +593,8 @@ class ACMEAccount(object):
|
|||
continue
|
||||
if parse_json_result:
|
||||
result = decoded_result
|
||||
else:
|
||||
result = content
|
||||
except ValueError:
|
||||
raise ModuleFailException("Failed to parse the ACME response: {0} {1}".format(url, content))
|
||||
else:
|
||||
|
@ -622,7 +624,7 @@ class ACMEAccount(object):
|
|||
try:
|
||||
content = resp.read()
|
||||
except AttributeError:
|
||||
content = info.get('body')
|
||||
content = info.pop('body')
|
||||
|
||||
# Process result
|
||||
if parse_json_result:
|
||||
|
|
Loading…
Reference in a new issue