问一个关于 https 证书的 certbot 的问题

2018-03-17 21:14:54 +08:00
 LeungJZ

根据官网教程 https://certbot.eff.org/lets-encrypt/ubuntuxenial-nginx 安装必须软件后

执行 $ sudo certbot --nginx 后报错:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
An unexpected error occurred:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 44: ordinal not in range(128)
Please see the logfiles in /var/log/letsencrypt for more details.

报错文件的内容是:

2018-03-17 13:06:34,407:DEBUG:certbot.main:certbot version: 0.21.1
2018-03-17 13:06:34,408:DEBUG:certbot.main:Arguments: []
2018-03-17 13:06:34,408:DEBUG:certbot.main:Discovered plugins: PluginsRegistry(PluginEntryPoint#manual,PluginEntryPoint#nginx,PluginEntryPoint#null,PluginEntryPoint#standalone,PluginEntryPoint#webroot)
2018-03-17 13:06:34,417:DEBUG:certbot.log:Root logging level set at 20
2018-03-17 13:06:34,418:INFO:certbot.log:Saving debug log to /var/log/letsencrypt/letsencrypt.log
2018-03-17 13:06:34,419:DEBUG:certbot.plugins.selection:Requested authenticator None and installer None
2018-03-17 13:06:34,731:DEBUG:certbot.log:Exiting abnormally:
Traceback (most recent call last):
  File "/usr/bin/certbot", line 11, in <module>
    load_entry_point('certbot==0.21.1', 'console_scripts', 'certbot')()
  File "/usr/lib/python3/dist-packages/certbot/main.py", line 1240, in main
    return config.func(config, plugins)
  File "/usr/lib/python3/dist-packages/certbot/main.py", line 1099, in certonly
    installer, auth = plug_sel.choose_configurator_plugins(config, plugins, "certonly")
  File "/usr/lib/python3/dist-packages/certbot/plugins/selection.py", line 194, in choose_configurator_plugins
    authenticator = pick_authenticator(config, req_auth, plugins)
  File "/usr/lib/python3/dist-packages/certbot/plugins/selection.py", line 40, in pick_authenticator
    config, default, plugins, question, (interfaces.IAuthenticator,))
  File "/usr/lib/python3/dist-packages/certbot/plugins/selection.py", line 77, in pick_plugin
    verified.prepare()
  File "/usr/lib/python3/dist-packages/certbot/plugins/disco.py", line 248, 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 248, in <listcomp>
    return [plugin_ep.prepare() for plugin_ep in six.itervalues(self._plugins)]
  File "/usr/lib/python3/dist-packages/certbot/plugins/disco.py", line 130, in prepare
    self._initialized.prepare()
  File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 131, in prepare
    self.parser = parser.NginxParser(self.conf('server-root'))
  File "/usr/lib/python3/dist-packages/certbot_nginx/parser.py", line 38, in __init__
    self.load()
  File "/usr/lib/python3/dist-packages/certbot_nginx/parser.py", line 45, in load
    self._parse_recursively(self.config_root)
  File "/usr/lib/python3/dist-packages/certbot_nginx/parser.py", line 66, in _parse_recursively
    self._parse_recursively(subentry[1])
  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 206, 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.5/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 44: ordinal not in range(128)

服务器是 ubuntu 16.04 nginx

4724 次点击
所在节点    Linux
13 条回复
dejavuwind
2018-03-17 21:49:54 +08:00
没怎么搞过 python,看这最后一行报错好像是跟 python 的默认编码有关?参考一下 SO 的这个
https://stackoverflow.com/questions/21129020/how-to-fix-unicodedecodeerror-ascii-codec-cant-decode-byte
LeungJZ
2018-03-17 22:13:03 +08:00
@dejavuwind
根本就不知道改哪个文件。。。
Kilerd
2018-03-17 23:05:44 +08:00
acme.sh please
LeungJZ
2018-03-17 23:13:53 +08:00
@Kilerd 什么意思?
Hello1995
2018-03-17 23:17:10 +08:00
orzfly
2018-03-17 23:22:31 +08:00
File "/usr/lib/python3/dist-packages/certbot_nginx/nginxparser.py", line 123, in load
return loads(_file.read())
File "/usr/lib/python3.5/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]

肯定是…… nginx 配置文件里有中文…
LeungJZ
2018-03-17 23:24:22 +08:00
@orzfly 要把配置文件中的中文全部去掉?
blankme
2018-03-17 23:26:53 +08:00
你加 certonly 好了,有了证书自己改 nginx 的配置
LeungJZ
2018-03-17 23:28:13 +08:00
@blankme
配置文件全部去掉中文,报错依旧。
@orzfly
certbot certonly 还是同样的报错。。。
mrcotter2013
2018-03-18 00:47:48 +08:00
错误提示中“ ordinal not in range(128)” 代表你的配置文件中使用了不在普通 ASCII 范围内,使用了特殊字符串,去掉
LeungJZ
2018-03-18 00:49:59 +08:00
@mrcotter2013
额比如呢??这个我不知道有哪些。配置文件略多。
mrcotter2013
2018-03-18 00:56:02 +08:00
@LeungJZ #11 查 ASCII 表,'0xe6' 代表 'æ',搜索你的文件中是否有这个字符
FEDT
2018-06-30 03:12:29 +08:00
@orzfly 太感谢了。。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/438988

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX