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

nginx authenticator crashes parsing non-ASCII text in comments in configuration files #5592

Open
schoen opened this Issue Feb 18, 2018 · 5 comments

Comments

4 participants
@schoen
Copy link
Contributor

schoen commented Feb 18, 2018

According to

https://community.letsencrypt.org/t/ascii-codec-cant-decode-byte-0xe6-in-position-1-ordinal-not-in-range-128-skipping/53394

the authenticator crashed with

‘ascii’ codec can’t decode byte 0xe6 in position 1: ordinal not in range(128)

at some point when processing an nginx config file containing Chinese-language text in comments. This was with certbot-auto, so it's presumably Certbot 0.21.1.

@ubani

This comment has been minimized.

Copy link

ubani commented Feb 18, 2018

Happens also on Apache.

@schoen

This comment has been minimized.

Copy link
Contributor Author

schoen commented Feb 18, 2018

In that case it's not necessarily the authenticator, but might be some other part of the codebase. @ubani, do you see this only during renewal, or also at initial issuance? Do you have logs from /var/log/letsencrypt that might show where in the process the crash occurs?

@schoen schoen added the area: apache label Feb 18, 2018

@ohemorange ohemorange added this to In progress in Unicode support Mar 26, 2018

@ohemorange ohemorange moved this from In progress to To do in Unicode support Apr 11, 2018

@belegnar

This comment has been minimized.

Copy link

belegnar commented Dec 3, 2018

Trouble point is

  File "/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot_nginx/nginxparser.py", line 98, in __str__
    return ''.join(self)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 2: ordinal not in range(128)
@idavydov

This comment has been minimized.

Copy link

idavydov commented Jan 21, 2019

Full stacktrace:

Traceback was:
Traceback (most recent call last):
  File "/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/renewal.py", line 452, in handle_renewal_request
    main.renew_cert(lineage_config, plugins, renewal_candidate)
  File "/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/main.py", line 1192, in renew_cert
    renewed_lineage = _get_and_save_cert(le_client, config, lineage=lineage)
  File "/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/main.py", line 116, in _get_and_save_cert
    renewal.renew_cert(config, domains, le_client, lineage)
  File "/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/renewal.py", line 310, in renew_cert
    new_cert, new_chain, new_key, _ = le_client.obtain_certificate(domains, new_key)
  File "/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/client.py", line 353, in obtain_certificate
    orderr = self._get_order_and_authorizations(csr.data, self.config.allow_subset_of_names)
  File "/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/client.py", line 389, in _get_order_and_authorizations
    authzr = self.auth_handler.handle_authorizations(orderr, best_effort)
  File "/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/auth_handler.py", line 75, in handle_authorizations
    resp = self._solve_challenges(aauthzrs)
  File "/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/auth_handler.py", line 132, in _solve_challenges
    resp = self.auth.perform(all_achalls)
  File "/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot_nginx/configurator.py", line 1068, in perform
    http_response = http_doer.perform()
  File "/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot_nginx/http_01.py", line 60, in perform
    self.configurator.save("HTTP Challenge", True)
  File "/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot_nginx/configurator.py", line 998, in save
    self.parser.filedump(ext='')
  File "/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot_nginx/parser.py", line 243, in filedump
    out = nginxparser.dumps(tree)
  File "/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot_nginx/nginxparser.py", line 134, in dumps
    return str(RawNginxDumper(blocks.spaced))
  File "/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot_nginx/nginxparser.py", line 98, in __str__
    return ''.join(self)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 12: ordinal not in range(128)
@idavydov

This comment has been minimized.

Copy link

idavydov commented Jan 21, 2019

I followed this advice and inserted the following lines into /opt/eff.org/certbot/venv/lib/python2.7/site-packages/certbot_nginx/parser.py:

import sys
reload(sys)
sys.setdefaultencoding('utf8')

Worked for me.

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