UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 6097: invalid continuation byte

hi there,

ubuntu server 18.04
i tried this command :
sudo certbot --expand -d abc.toto.com

i get this error :
Saving debug log to /var/log/letsencrypt/letsencrypt.log
An unexpected error occurred:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 6097: invalid continuation byte
Please see the logfiles in /var/log/letsencrypt for more details.

here is the log file :
2022-06-28 18:17:09,199:ERROR:certbot.log:An unexpected error occurred:
2022-06-28 18:18:22,825:DEBUG:certbot.main:certbot version: 0.31.0
2022-06-28 18:18:22,826:DEBUG:certbot.main:Arguments: ['--expand', '-d', 'abc.toto.com']
2022-06-28 18:18:22,826:DEBUG:certbot.main:Discovered plugins: PluginsRegistry(PluginEntryPoint#manual,PluginEntryPoint#nginx,PluginEntryPoint#null,PluginEntryPoint#standalone,PluginEntryPoint#webroot)
2022-06-28 18:18:22,834:DEBUG:certbot.log:Root logging level set at 20
2022-06-28 18:18:22,835:INFO:certbot.log:Saving debug log to /var/log/letsencrypt/letsencrypt.log
2022-06-28 18:18:22,836:DEBUG:certbot.plugins.selection:Requested authenticator None and installer None
2022-06-28 18:18:22,856: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 1101, in run
installer, authenticator = plug_sel.choose_configurator_plugins(config, plugins, "run")
File "/usr/lib/python3/dist-packages/certbot/plugins/selection.py", line 225, in choose_configurator_plugins
authenticator = installer = pick_configurator(config, req_inst, plugins)
File "/usr/lib/python3/dist-packages/certbot/plugins/selection.py", line 25, in pick_configurator
(interfaces.IAuthenticator, interfaces.IInstaller))
File "/usr/lib/python3/dist-packages/certbot/plugins/selection.py", line 106, in pick_plugin
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
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
File "/usr/lib/python3/dist-packages/certbot_nginx/parser.py", line 45, in load
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.6/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 6097: invalid continuation byte
2022-06-28 18:18:22,858:ERROR:certbot.log:An unexpected error occurred:

i have read many things, but no way to really solve this problem and use certbot..
if one of you have the solution.. it would be very nice to share it..

It seems you have an invalid UTF-8 character in your nginx configuration. Let's try to find it by searching for it.. The following command should probably do the trick. Or at least a trick:

find /etc/nginx/ -type f -printf 'Processing %p\n' -exec sh -c "xxd -g 1 {} | grep -B 2 -A 2 e0" \;

thanks for your answer, i used the command you gave me, it results with 14838 lines of unreadable text like this :

00000c0: 34 30 34 3b 0a 0a 23 20 42 79 70 61 73 73 20 74 404;..# Bypass t
000000d0: 68 65 20 66 61 63 74 20 74 68 61 74 20 74 72 79 he fact that try
000000e0: 5f 66 69 6c 65 73 20 72 65 73 65 74 73 20 24 66 _files resets $f
000000f0: 61 73 74 63 67 69 5f 70 61 74 68 5f 69 6e 66 6f astcgi_path_info
00000100: 0a 23 20 73 65 65 3a 20 68 74 74 70 3a 2f 2f 74 .# see: http://t
Processing /etc/nginx/snippets/snakeoil.conf

what can i do with that..?

so i found the solution when looking at my nginx.conf, and there was an "à" letter in a line, so i corrected it, and now i can expand my subdomain name..


1 Like

We need to finetune it a little bit more, I didn't realise it would also trigger on the offset in the front of the lines of output.

find /etc/nginx/ -type f -printf 'Processing %p\n' -exec sh -c "xxd -g 1 {} | grep -B 2 -A 2 -P '(?<=.{10})e0'" \;

Ah OK, you've found the culprit already :slight_smile:

You might want to upgrade your Certbot to a non-ancient version. This kind of issues might be fixed in the mean time.

Also note that when using --expand you should put ALL the required hostnames on the command line, NOT just the one you want to have added.. Certbot works weird in that way...


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