You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Debian系统使用Certbot续签证书时遇ImportError错误求助

解决Certbot续签时ImportError: cannot import name 'FILETYPE_PEM'错误

这个错误是因为你使用的Certbot 1.12.0版本过旧,与Debian 12自带的高版本pyOpenSSL不兼容——新版pyOpenSSL已移除/变更了FILETYPE_PEM常量的位置,旧版Certbot仍在尝试从OpenSSL.crypto导入它。

以下是两种可靠的解决方法:

方法一:升级Certbot到兼容版本(推荐)

Debian 12官方仓库提供的Certbot版本已适配系统依赖,直接通过apt安装即可:

  1. 卸载旧版Certbot
    • 若通过pip安装:pip uninstall -y certbot
    • 若通过apt安装:apt remove -y certbot
  2. 安装适配的Certbot及Nginx插件:
    apt update && apt install -y certbot python3-certbot-nginx
    
  3. 重新执行续签命令:certbot renew

如果官方仓库版本仍不满足需求,也可以用snap安装最新版Certbot(独立环境,不依赖系统Python库):

  1. 安装snap(Debian 12默认已预装):apt install -y snapd
  2. 安装Certbot:snap install --classic certbot
  3. 创建软链接让系统全局可用:ln -s /snap/bin/certbot /usr/bin/certbot
  4. 执行续签:certbot renew

方法二:降级pyOpenSSL到兼容版本(不推荐,可能影响其他应用)

如果必须保留旧版Certbot,可以安装与它兼容的pyOpenSSL版本:

pip install pyOpenSSL==21.0.0

安装完成后重新执行certbot renew即可。

内容的提问来源于stack exchange,提问作者ArnaudB

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.23 19:00:59