Cerbot UnicodeDecodeError 'utf-8' codec can't decode byte

My domain is: my domain name is in this form ummogep47.fr

I ran this command: certbot --apache

It produced this output: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 62: invalid continuation byte

My web server is (include version): Apache

The operating system my web server runs on is (include version): I have Debian version 11 and all packages are up to date.

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 2.9.0

log tells me:
2024-02-14 09:13:29,457:DEBUG:certbot._internal.error_handler:Calling registered functions
2024-02-14 09:13:29,459:DEBUG:certbot._internal.display.obj:Notifying user: Could not install certificate
2024-02-14 09:13:29,460:DEBUG:certbot._internal.log:Exiting abnormally:
Traceback (most recent call last):
File "/snap/certbot/3643/bin/certbot", line 8, in
sys.exit(main())
File "/snap/certbot/3643/lib/python3.8/site-packages/certbot/main.py", line 19, in main
return internal_main.main(cli_args)
File "/snap/certbot/3643/lib/python3.8/site-packages/certbot/_internal/main.py", line 1894, in main
return config.func(config, plugins)
File "/snap/certbot/3643/lib/python3.8/site-packages/certbot/_internal/main.py", line 1464, in run
_install_cert(config, le_client, domains, new_lineage)
File "/snap/certbot/3643/lib/python3.8/site-packages/certbot/_internal/main.py", line 1058, in _install_cert
le_client.deploy_certificate(domains, path_provider.key_path, path_provider.cert_path,
File "/snap/certbot/3643/lib/python3.8/site-packages/certbot/_internal/client.py", line 657, in deploy_certificate
self.installer.deploy_cert(
File "/snap/certbot/3643/lib/python3.8/site-packages/certbot_apache/_internal/configurator.py", line 528, in deploy_cert
vhosts = self.choose_vhosts(domain)
File "/snap/certbot/3643/lib/python3.8/site-packages/certbot_apache/_internal/configurator.py", line 554, in choose_vhosts
return [self.choose_vhost(domain, create_if_no_ssl)]
File "/snap/certbot/3643/lib/python3.8/site-packages/certbot_apache/_internal/configurator.py", line 736, in choose_vhost
vhost = self.make_vhost_ssl(vhost)
File "/snap/certbot/3643/lib/python3.8/site-packages/certbot_apache/_internal/configurator.py", line 1373, in make_vhost_ssl
self._copy_create_ssl_vhost_skeleton(nonssl_vhost, ssl_fp)
File "/snap/certbot/3643/lib/python3.8/site-packages/certbot_apache/_internal/configurator.py", line 1513, in _copy_create_ssl_vhost_skeleton
orig_contents = self._get_vhost_block(vhost)
File "/snap/certbot/3643/lib/python3.8/site-packages/certbot_apache/_internal/configurator.py", line 1619, in _get_vhost_block
vh_contents = fh.read(span_end-span_start).split("\n")
File "/snap/certbot/3643/bin/../usr/lib/python3.8/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 62: invalid continuation byte
2024-02-14 09:13:29,461:ERROR:certbot._internal.log:An unexpected error occurred:
2024-02-14 09:13:29,462:ERROR:certbot._internal.log:UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 62: invalid continuation byte

does your Apache config have invalid or non ASCII character?

2 Likes

I don't think so because I managed to generate cerbot certificates for 3 other sites on this same server.

A hex e9 is an accented e. Is there one of those in your Apache config?

If you can't find it you could try using --webroot method instead. It does not rely on reading / decoding the Apache config.

I don't know how to type one but it looks like:
image

1 Like

Thanks MikeMcQ, I didn't find an "é" occurrence in my apache2.conf but the certbot certonly –webroot command allowed me to generate the certificate without errors.

2 Likes

Great. The char could have been in any file included by your base Apache conf too.

Glad the webroot got you working.

3 Likes

Yes indeed I also looked in my php.ini, I found nothing, knowing that this error does not occur for my other sites.

1 Like

This might help, depending on how much grep likes unicode:

grep -r é /path/to/dir

3 Likes

Might not actually be é, depending on what character encodings are used. Probably better to look for the byte itself, maybe something like

LC_ALL=C grep -r -P '\xe9' /path

though I haven't tried it.

5 Likes

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