V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
LeungJZ
V2EX  ›  Linux

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

  •  1
     
  •   LeungJZ ·
    JZLeung · 2018-03-17 21:14:54 +08:00 · 4881 次点击
    这是一个创建于 2441 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    13 条回复    2018-06-30 03:12:29 +08:00
    dejavuwind
        1
    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
        2
    LeungJZ  
    OP
       2018-03-17 22:13:03 +08:00
    @dejavuwind
    根本就不知道改哪个文件。。。
    Kilerd
        3
    Kilerd  
       2018-03-17 23:05:44 +08:00
    acme.sh please
    LeungJZ
        4
    LeungJZ  
    OP
       2018-03-17 23:13:53 +08:00
    @Kilerd 什么意思?
    Hello1995
        5
    Hello1995  
       2018-03-17 23:17:10 +08:00
    orzfly
        6
    orzfly  
       2018-03-17 23:22:31 +08:00   ❤️ 1
    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
        7
    LeungJZ  
    OP
       2018-03-17 23:24:22 +08:00
    @orzfly 要把配置文件中的中文全部去掉?
    blankme
        8
    blankme  
       2018-03-17 23:26:53 +08:00
    你加 certonly 好了,有了证书自己改 nginx 的配置
    LeungJZ
        9
    LeungJZ  
    OP
       2018-03-17 23:28:13 +08:00
    @blankme
    配置文件全部去掉中文,报错依旧。
    @orzfly
    certbot certonly 还是同样的报错。。。
    mrcotter2013
        10
    mrcotter2013  
       2018-03-18 00:47:48 +08:00
    错误提示中“ ordinal not in range(128)” 代表你的配置文件中使用了不在普通 ASCII 范围内,使用了特殊字符串,去掉
    LeungJZ
        11
    LeungJZ  
    OP
       2018-03-18 00:49:59 +08:00
    @mrcotter2013
    额比如呢??这个我不知道有哪些。配置文件略多。
    mrcotter2013
        12
    mrcotter2013  
       2018-03-18 00:56:02 +08:00
    @LeungJZ #11 查 ASCII 表,'0xe6' 代表 'æ',搜索你的文件中是否有这个字符
    FEDT
        13
    FEDT  
       2018-06-30 03:12:29 +08:00
    @orzfly 太感谢了。。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   982 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 20:25 · PVG 04:25 · LAX 12:25 · JFK 15:25
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.