Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
UnicodeDecodeError: 'utf-8' codec can't decode #5646
If you're having trouble using Certbot and aren't sure you've found a bug or
My operating system is (include version):
I installed Certbot with (certbot-auto, OS package manager, pip, etc):
$ sudo apt-get update $ sudo apt-get install software-properties-common $ sudo add-apt-repository ppa:certbot/certbot $ sudo apt-get update $ sudo apt-get install python-certbot-nginx
I ran this command and it produced this output:
# sudo certbot --nginx certonly Saving debug log to /var/log/letsencrypt/letsencrypt.log An unexpected error occurred: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd7 in position 650: invalid continuation byte Please see the logfiles in /var/log/letsencrypt for more details.
Certbot's behavior differed from what I expected because:
Seems the same issue in Apache in #5211 , not sure it's fixed? What's more, my server is Nginx, I do use some utf-8 words (Chinese, and all they are in comment after # tag) in my Nginx conf files.
I was using the older version of Certbot before, and it worked fine, today I find it cannot obtain new certificates and so installed the new version and got this problem.
Here is a Certbot log showing the issue (if available):
Logs are stored in
Hey @mashirozx. Thanks a lot for the detailed bug report.
We'll try and look into this soon, but we'd gladly take help around this issue.
As noted elsewhere, this is because nginx
I could not reproduce the bug in a development setup, only with some remote server with a "rawer" configuration. In fact, because I was missing some configuration, I was using the
The solution is to generate an UTF-8 locale, such as
Pinging @bmw as this looks like an issue caused by users' setup, not certbot itself.
Using the following command:
Found mine in
Ubuntu 18.04, locale set to en_US.UTF-8, and just in case setting the env var:
LANG=en_US.UTF-8 sudo ./certbot-auto --nginx
I suspect I am having a similar issue.
I had this error but it was due to odd characters in the comments of the nginx config file for the site I was trying to get a certificate for.
Following @egberts advice and command:
And then deleting the offending lines (since they were comments it didn't matter) solved the issue.
Batch-editing random conf files without understanding the underlying issue, what could possibly go wrong? Let's fix the symptoms instead of getting to the root issue which has already been identified in this thread!
Again, certbot modifications shall be transparent. However broken they seem, if the conf files work for their target software (nginx, apache, whatever), certbot should not die trying to modify them. Or at least it should die with a better explanation.