New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 2: ordinal not in range(128) #5509

yaoshanliang opened this Issue Jan 27, 2018 · 7 comments


None yet
8 participants
Copy link

yaoshanliang commented Jan 27, 2018

My operating system is (include version):

ubuntu 14.04

I installed Certbot with (certbot-auto, OS package manager, pip, etc):

source code

I ran this command and it produced this output:

./letsencrypt-auto certonly -d

Certbot's behavior differed from what I expected because:

Requesting to rerun ./letsencrypt-auto with root privileges...
Saving debug log to /var/log/letsencrypt/letsencrypt.log

How would you like to authenticate with the ACME CA?
1: Apache Web Server plugin - Beta (apache)
2: Nginx Web Server plugin - Alpha (nginx)
3: Spin up a temporary webserver (standalone)
4: Place files in webroot directory (webroot)
Select the appropriate number [1-4] then [enter] (press 'c' to cancel): 2
Plugins selected: Authenticator nginx, Installer None
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for
Cleaning up challenges
An unexpected error occurred:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 2: ordinal not in range(128)
Please see the logfiles in /var/log/letsencrypt for more details.

Here is a Certbot log showing the issue (if available):

Logs are stored in /var/log/letsencrypt by default. Feel free to redact domains, e-mail and IP addresses as you see fit.
2018-01-27 09:34:54,243:DEBUG:certbot.log:Exiting abnormally:
Traceback (most recent call last):
  File "/opt/", line 11, in <module>
  File "/opt/", line 1240, in main
    return config.func(config, plugins)
  File "/opt/", line 1120, in certonly
    lineage = _get_and_save_cert(le_client, config, domains, certname, lineage)
  File "/opt/", line 118, in _get_and_save_cert
    lineage = le_client.obtain_and_enroll_certificate(domains, certname)
  File "/opt/", line 357, in obtain_and_enroll_certificate
    certr, chain, key, _ = self.obtain_certificate(domains)
  File "/opt/", line 318, in obtain_certificate
  File "/opt/", line 74, in get_authorizations
    resp = self._solve_challenges()
  File "/opt/", line 115, in _solve_challenges
    resp = self.auth.perform(self.achalls)
  File "/opt/", line 862, in perform
    http_response = http_doer.perform()
  File "/opt/", line 61, in perform"HTTP Challenge", True)
  File "/opt/", line 792, in save
  File "/opt/", line 242, in filedump
    out = nginxparser.dumps(tree)
  File "/opt/", line 134, in dumps
    return str(RawNginxDumper(blocks.spaced))
  File "/opt/", line 98, in __str__
    return ''.join(self)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 2: ordinal not in range(128)

Here is the relevant nginx server block or Apache virtualhost for the domain I am configuring:


This comment has been minimized.

Copy link

SwartzCr commented Jan 29, 2018

This is a duplicate of #5236 - so I'm going to close this as a duplicate of that, feel free to follow up in that thread


This comment has been minimized.

Copy link

egberts commented Aug 26, 2018

Using the following command:

grep -r -P '[^\x00-\x7f]' /etc/apache2 /etc/letsencrypt /etc/nginx

Found mine in

/etc/letsencrypt/options-ssl-nginx.conf:        # The following CSP directives don't use default-src as 

Using shed, I found the offending sequence. It turned out to be an editor mistake.

00008099:     C2  194 302 11000010
00008100:     A0  160 240 10100000
00008101:  d  64  100 144 01100100
00008102:  e  65  101 145 01100101
00008103:  f  66  102 146 01100110
00008104:  a  61  097 141 01100001
00008105:  u  75  117 165 01110101
00008106:  l  6C  108 154 01101100
00008107:  t  74  116 164 01110100
00008108:  -  2D  045 055 00101101
00008109:  s  73  115 163 01110011
00008110:  r  72  114 162 01110010
00008111:  c  63  099 143 01100011
00008112:     C2  194 302 11000010
00008113:     A0  160 240 10100000

This comment has been minimized.

Copy link

TommyZG commented Sep 2, 2018

Thank you, @egberts on that command - in my case there was an apostrophe in two comments. Removing it made everything work again.


This comment has been minimized.

Copy link

sahil5695 commented Sep 15, 2018

@egberts Thankyou so much


This comment has been minimized.

Copy link

da3020 commented Sep 18, 2018

Hi! The reason is that if you have some non ascii letters in nginx config (even in comments!!!) it will not work.


This comment has been minimized.

Copy link

chn-yang commented Nov 13, 2018

@da3020 saved me!


This comment has been minimized.

Copy link

barrer commented Nov 29, 2018

You are right! I think maybe certbot-auto can support the unicode character set later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment