certbot renew / certonly dash error : 'ascii' codec can't decode byte

certbot renew / certonly dash error : 'ascii' codec can't decode byte

我在 lets-encrypt certbot 上遇到了一个奇怪的错误,它似乎与我的第二个域名中存在破折号有关(在真实的位置 8 对应于所述破折号的位置)。

无论我尝试续订还是创建新证书,都会出现错误。原始(功能)证书是使用 certbot no pb 生成的...

./certbot-auto certonly --nginx -d domain1 -d domain2
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Cert is due for renewal, auto-renewing...
Renewing an existing certificate
Performing the following challenges:
tls-sni-01 challenge for domain1
tls-sni-01 challenge for domain-2
Cleaning up challenges
An unexpected error occurred:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 8: ordinal not in range(128)

我可以从这里做什么?

我确实在该文件中有一个非 ascii 字符,解决此类问题的有用命令是:

grep -nRP '[\x80-\xFF]' /etc/nginx

其中 /etc/nginx 是您要查找非 ascii 字符的 directory/file。 [\x80-\xFF] 是您要查找的范围(在本例中为非 ascii)。

使用以下命令:

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

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

使用 shed,我发现了有问题的序列。原来是编辑失误。 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

使用编辑器(即 vim),我编辑出了有问题的字节序列。

应该注意的是,这也可能是使用非 ASCII 区域设置编辑 Web 服务器配置文件的结果,但 certbot cron 作业不会这样做,这反过来会导致自动续订尝试失败。

同样,来自网络服务器配置文件的任何 include 文件都由 certbot 解析,因此可能需要在典型目录之外进行检查。