如何停止 certbot 的弃用警告?

如何停止 certbot 的弃用警告?

我设置了一个 cron 来更新certbot。它每天都会发送弃用警告。如何停止弃用警告?

Cron <root@ip-99-99-99-99> /root/certbot-auto renew --quiet

/root/.local/share/letsencrypt/lib/python2.6/site-packages/cryptography/__init__.py:26: DeprecationWarning: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of cryptography will drop support for Python 2.6
  DeprecationWarning

我尝试提交一个错误报告,但他们将其关闭了。https://github.com/certbot/certbot/issues/3984

我尝试安装 Python2.7,但无法让 certbot 使用 Python2.7 运行。

[root@kizbit ~]# scl enable python27 "python --version"
Python 2.7.8

[root@kizbit ~]# scl enable python27 "/root/certbot-auto renew"
/root/.local/share/letsencrypt/lib/python2.6/site-packages/cryptography/__init__.py:26: DeprecationWarning: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of cryptography will drop support for Python 2.6
  DeprecationWarning

它仍然使用 Python 2.6,并且仍然会产生警告。我还尝试过:

[root@kizbit ~]# scl enable python27 "python /root/certbot-auto renew"
  File "/root/certbot-auto", line 18
    if [ -z "$XDG_DATA_HOME" ]; then
                           ^
SyntaxError: invalid syntax

使用 2.6 它可以工作但是会贬值:

[root@kizbit ~]# /root/certbot-auto renew
/root/.local/share/letsencrypt/lib/python2.6/site-packages/cryptography/__init__.py:26: DeprecationWarning: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of cryptography will drop support for Python 2.6
  DeprecationWarning

Centos 6.8,certbot 0.12.0

答案1

您的问题已关闭,因为它与那个包含进一步解释的链接

没有办法解决这个问题:你系统上可用的 Python 版本已经过时了。一位成员请求发送“它仍在发生”的垃圾邮件不会有帮助已经帮助。如果该问题对您很重要,请随时提交 PR。

否则,我不建议将 certbot 输出删除到/dev/null,...但如果这些警告确实有问题,那么您可以考虑丢弃它们。

答案2

2015 年左右,Let's Encrypt 社区提出了几种获取 2.7、CentOS 软件集合或第三方存储库的方法。 Redhat / CentOS 6.x 用户需要 python 2.7

这相当于安装 python27 软件包并在客户端中将 python2 替换为 python27。由于 certbot 适用于 2.6,因此可能不是绝对必要的,但这是获取较新软件的一个很好的练习。

从长远来看,您将希望迁移到较新版本的 CentOS。

答案3

作为一种临时的解决方法,您可以在 cron 条目中尝试如下操作:

certbot renew ... 2>&1 | grep -v DeprecationWarning

答案4

我在 CentOS 6 上安装了 Python2.7新加坡

yum install -y centos-release-scl
yum install -y python27
# scl enable python27 "python -V"
Python 2.7.8

然后你还必须删除

rm -r ~/.local/share/letsencrypt

然后重新安装一些与 Python 2.7 相关的东西(库?配置?),只需运行它即可

scl enable python27 "./certbot-auto"

在 crontab 里面:

@daily scl enable python27 "/root/certbot-auto renew --quiet"

相关内容