1
0
mirror of https://github.com/certbot/certbot.git synced 2026-01-26 07:41:33 +03:00

Use UTF-8 for renewal configuration file encoding (#8789)

This commit is contained in:
osirisinferi
2021-05-16 15:17:41 +02:00
committed by GitHub
parent bc23e07ee5
commit 5040495741
3 changed files with 16 additions and 8 deletions

View File

@@ -46,6 +46,7 @@ More details about these changes can be found on our GitHub repo.
* The module `acme.magic_typing` is deprecated and will be removed in a future release.
Please use the built-in module `typing` instead.
* The DigitalOcean plugin now creates TXT records for the DNS-01 challenge with a lower 30s TTL.
* Use UTF-8 encoding for renewal configuration files
### Fixed

View File

@@ -616,7 +616,9 @@ def _delete_if_appropriate(config):
# don't delete if the archive_dir is used by some other lineage
archive_dir = storage.full_archive_path(
configobj.ConfigObj(storage.renewal_file_for_certname(config, config.certname)),
configobj.ConfigObj(
storage.renewal_file_for_certname(config, config.certname),
encoding='utf-8', default_encoding='utf-8'),
config, config.certname)
try:
cert_manager.match_and_check_overlaps(config, [lambda x: archive_dir],

View File

@@ -67,13 +67,16 @@ def cert_path_for_cert_name(config: interfaces.IConfig, cert_name: str) -> str:
"""
cert_name_implied_conf = renewal_file_for_certname(config, cert_name)
return configobj.ConfigObj(cert_name_implied_conf)["fullchain"]
return configobj.ConfigObj(
cert_name_implied_conf, encoding='utf-8', default_encoding='utf-8')["fullchain"]
def config_with_defaults(config=None):
"""Merge supplied config, if provided, on top of builtin defaults."""
defaults_copy = configobj.ConfigObj(constants.RENEWER_DEFAULTS)
defaults_copy.merge(config if config is not None else configobj.ConfigObj())
defaults_copy = configobj.ConfigObj(
constants.RENEWER_DEFAULTS, encoding='utf-8', default_encoding='utf-8')
defaults_copy.merge(config if config is not None else configobj.ConfigObj(
encoding='utf-8', default_encoding='utf-8'))
return defaults_copy
@@ -114,7 +117,7 @@ def write_renewal_config(o_filename, n_filename, archive_dir, target, relevant_d
:rtype: configobj.ConfigObj
"""
config = configobj.ConfigObj(o_filename)
config = configobj.ConfigObj(o_filename, encoding='utf-8', default_encoding='utf-8')
config["version"] = certbot.__version__
config["archive_dir"] = archive_dir
for kind in ALL_FOUR:
@@ -196,7 +199,7 @@ def update_configuration(lineagename, archive_dir, target, cli_config):
write_renewal_config(config_filename, temp_filename, archive_dir, target, values)
filesystem.replace(temp_filename, config_filename)
return configobj.ConfigObj(config_filename)
return configobj.ConfigObj(config_filename, encoding='utf-8', default_encoding='utf-8')
def get_link_target(link):
@@ -324,7 +327,8 @@ def delete_files(config, certname):
full_default_archive_dir = full_archive_path(None, config, certname)
full_default_live_dir = _full_live_path(config, certname)
try:
renewal_config = configobj.ConfigObj(renewal_filename)
renewal_config = configobj.ConfigObj(
renewal_filename, encoding='utf-8', default_encoding='utf-8')
except configobj.ConfigObjError:
# config is corrupted
logger.warning("Could not parse %s. You may wish to manually "
@@ -434,7 +438,8 @@ class RenewableCert(interfaces.RenewableCert):
# systemwide renewal configuration; self.configfile should be
# used to make and save changes.
try:
self.configfile = configobj.ConfigObj(config_filename)
self.configfile = configobj.ConfigObj(
config_filename, encoding='utf-8', default_encoding='utf-8')
except configobj.ConfigObjError:
raise errors.CertStorageError(
"error parsing {0}".format(config_filename))