Compare commits

...

2 Commits

Author SHA1 Message Date
Brad Warren
dca8f345cb set response.encoding in acme 2021-08-20 11:53:35 -07:00
Brad Warren
87ee0470e6 Revert "add chardet dep (#8965)"
This reverts commit 1129d850d3.
2021-08-20 11:38:41 -07:00
2 changed files with 10 additions and 8 deletions

View File

@@ -1149,13 +1149,19 @@ class ClientNetwork:
host, path, _err_no, err_msg = m.groups()
raise ValueError("Requesting {0}{1}:{2}".format(host, path, err_msg))
# If content is DER, log the base64 of it instead of raw bytes, to keep
# binary data out of the logs.
# If the Content-Type is DER or an Accept header was sent in the
# request, the response may not be UTF-8 encoded. In this case, we
# don't set response.encoding and log the base64 response instead of
# raw bytes to keep binary data out of the logs. This code can be
# simplified to only check for an Accept header in the request when
# ACMEv1 support is dropped.
debug_content: Union[bytes, str]
if response.headers.get("Content-Type") == DER_CONTENT_TYPE:
if (response.headers.get("Content-Type") == DER_CONTENT_TYPE or
"Accept" in kwargs["headers"]):
debug_content = base64.b64encode(response.content)
else:
debug_content = response.content.decode("utf-8")
response.encoding = "utf-8"
debug_content = response.text
logger.debug('Received response:\nHTTP %d\n%s\n\n%s',
response.status_code,
"\n".join("{0}: {1}".format(k, v)

View File

@@ -6,10 +6,6 @@ from setuptools import setup
version = '1.19.0.dev0'
install_requires = [
# This dependency just exists to ensure that chardet is installed along
# with requests so it will use it instead of charset_normalizer. See
# https://github.com/certbot/certbot/issues/8964 for more info.
'chardet',
'cryptography>=2.1.4',
# formerly known as acme.jose:
# 1.1.0+ is required to avoid the warnings described at