Certbot UnicodeDecodeError: 'utf-8' codec

My domain is: frq-clan.de

I ran this command: certbot certonly --nginx (also happens without certonly)

It produced this output:

An unexpected error occurred:
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xe4 in position 2467: invalid continuation byte
Please see the logfiles in /var/log/letsencrypt for more details.

log tells me:

File “/usr/lib/python3.7/codecs.py”, line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xe4 in position 2467: invalid continuation byte
2020-03-24 22:56:51,871:ERROR:certbot.log:An unexpected error occurred:

My web server is (include version): nginx/1.14.2

The operating system my web server runs on is (include version): Debian 10

My hosting provider, if applicable, is: self hosted

I can login to a root shell on my machine (yes or no, or I don’t know): yes

I’m using a control panel to manage my site (no, or provide the name and version of the control panel): no

The version of my client is (e.g. output of certbot --version or certbot-auto --version if you’re using Certbot): certbot 0.31.0

1 Like

Can you post more of the traceback from Python, so we can see what part of Certbot’s functionality was running when the invalid UTF-8 sequence was encountered?

Check your nginx configuration as a first pass:

grep -RP '[^\x00-\x7f]' /etc/nginx/
find /etc/nginx | grep -P '[^\x00-\x7f]'

(first command) grep ... doesnt give me any output
(second command)
root@frq-clan:~# find /etc/nginx | grep -P '[^\x00-\x7f]' /etc/nginx
grep: /etc/nginx: Is a directory

Alright, thanks. Please also post the full error stack.

2020-03-24 22:56:51,670:DEBUG:certbot.main:certbot version: 0.31.0
2020-03-24 22:56:51,670:DEBUG:certbot.main:Arguments: [’–nginx’]
2020-03-24 22:56:51,670:DEBUG:certbot.main:Discovered plugins: PluginsRegistry(PluginEntryPoint#manual,PluginEntryPoint#nginx,PluginEntryPoint#null,PluginEntryPoint#standalone,PluginEntryPoint#webroot)
2020-03-24 22:56:51,676:DEBUG:certbot.log:Root logging level set at 20
2020-03-24 22:56:51,676:INFO:certbot.log:Saving debug log to /var/log/letsencrypt/letsencrypt.log
2020-03-24 22:56:51,677:DEBUG:certbot.plugins.selection:Requested authenticator nginx and installer nginx
2020-03-24 22:56:51,845:DEBUG:certbot.log:Exiting abnormally:
Traceback (most recent call last):
File “/usr/bin/certbot”, line 11, in
load_entry_point(‘certbot==0.31.0’, ‘console_scripts’, ‘certbot’)()
File “/usr/lib/python3/dist-packages/certbot/main.py”, line 1365, in main
return config.func(config, plugins)
File “/usr/lib/python3/dist-packages/certbot/main.py”, line 1229, in certonly
installer, auth = plug_sel.choose_configurator_plugins(config, plugins, “certonly”)
File “/usr/lib/python3/dist-packages/certbot/plugins/selection.py”, line 228, in choose_configurator_plugins
installer = pick_installer(config, req_inst, plugins, installer_question)
File “/usr/lib/python3/dist-packages/certbot/plugins/selection.py”, line 32, in pick_installer
config, default, plugins, question, (interfaces.IInstaller,))
File “/usr/lib/python3/dist-packages/certbot/plugins/selection.py”, line 106, in pick_plugin
verified.prepare()
File “/usr/lib/python3/dist-packages/certbot/plugins/disco.py”, line 251, in prepare
return [plugin_ep.prepare() for plugin_ep in six.itervalues(self._plugins)]
File “/usr/lib/python3/dist-packages/certbot/plugins/disco.py”, line 251, in
return [plugin_ep.prepare() for plugin_ep in six.itervalues(self._plugins)]
File “/usr/lib/python3/dist-packages/certbot/plugins/disco.py”, line 132, in prepare
self._initialized.prepare()
File “/usr/lib/python3/dist-packages/certbot_nginx/configurator.py”, line 152, in prepare
self.parser = parser.NginxParser(self.conf(‘server-root’))
File “/usr/lib/python3/dist-packages/certbot_nginx/parser.py”, line 38, in init
self.load()
File “/usr/lib/python3/dist-packages/certbot_nginx/parser.py”, line 45, in load
self._parse_recursively(self.config_root)
File “/usr/lib/python3/dist-packages/certbot_nginx/parser.py”, line 66, in _parse_recursively
self._parse_recursively(subentry[1])
File “/usr/lib/python3/dist-packages/certbot_nginx/parser.py”, line 56, in _parse_recursively
trees = self._parse_files(filepath)
File “/usr/lib/python3/dist-packages/certbot_nginx/parser.py”, line 207, in _parse_files
parsed = nginxparser.load(_file)
File “/usr/lib/python3/dist-packages/certbot_nginx/nginxparser.py”, line 123, in load
return loads(_file.read())
File “/usr/lib/python3.7/codecs.py”, line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xe4 in position 2467: invalid continuation byte
2020-03-24 22:56:51,871:ERROR:certbot.log:An unexpected error occurred:

This can be closed.
I just checked my sites-available folder and i got a file in there with some character certbot doesnt like.
Thanks for your fast help.

1 Like

By the way, there is code that we’ve added to Certbot recently to give more specific feedback in this circumstance. Unfortunately due to the current pandemic, our release process has been delayed and so I don’t believe that code has made it into a publicly-released Certbot version yet. However, the inconvenient behavior of Certbot in this case is a known problem that we do intend to improve for other users in the future—my apologies that you’re among the Certbot users to encounter this annoying behavior.

The new version is still going to complain about non-UTF-8 encodings in nginx configuration files, but it will complain in a more useful and specific way. :slight_smile:

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.