技术解析

问一个关于 https 证书的 certbot 的问题
0
1975-02-24 15:34:29
idczone

根据官网教程 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 
    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 
    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


没怎么搞过 python,看这最后一行报错好像是跟 python 的默认编码有关?参考一下 SO 的这个
https://stackoverflow.com/questions/21129020/how-to-fix-unicodedecodeerror-ascii-codec-cant-decode-byte


根本就不知道改哪个文件。。。

acme.sh please

什么意思?

他的意思 https://github.com/Neilpang/acme.sh

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 配置文件里有中文…

要把配置文件中的中文全部去掉?

你加 certonly 好了,有了证书自己改 nginx 的配置


配置文件全部去掉中文,报错依旧。

certbot certonly 还是同样的报错。。。

错误提示中“ ordinal not in range(128)” 代表你的配置文件中使用了不在普通 ASCII 范围内,使用了特殊字符串,去掉


额比如呢??这个我不知道有哪些。配置文件略多。

查 ASCII 表,'0xe6' 代表 'æ',搜索你的文件中是否有这个字符

太感谢了。。

数据地带为您的网站提供全球顶级IDC资源
在线咨询
专属客服