From b837f218c9e8755fbc5e4a6d47a68c5fe8f7f81c Mon Sep 17 00:00:00 2001 From: Erica Portnoy Date: Wed, 31 Oct 2018 17:59:24 -0700 Subject: [PATCH] U mode on open --> newline=None --- certbot/crypto_util.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/certbot/crypto_util.py b/certbot/crypto_util.py index 942f8502f..7b558b060 100644 --- a/certbot/crypto_util.py +++ b/certbot/crypto_util.py @@ -458,8 +458,12 @@ def sha256sum(filename): :rtype: str """ sha256 = hashlib.sha256() - with open(filename, 'rU') as file_d: - sha256.update(file_d.read().encode('UTF-8')) + if six.PY2: + with open(filename, 'rU') as file_d: + sha256.update(file_d.read().encode('UTF-8')) + else: + with open(filename, 'r', newline=None) as file_d: + sha256.update(file_d.read().encode('UTF-8')) return sha256.hexdigest() def cert_and_chain_from_fullchain(fullchain_pem):