在统信uos上部署let's encrypt ssl证书需通过snap安装certbot,支持--nginx自动配置或--standalone手动申请,并配置systemd定时器实现90天自动续期。

如果您在统信UOS系统上需要为Web服务器(如Nginx或Apache)部署Let's Encrypt免费SSL证书,则需通过Certbot工具完成自动化申请与配置。以下是具体安装与使用Certbot的实操步骤:
一、安装Certbot及必要依赖
统信UOS基于Debian/Ubuntu体系,Certbot官方软件包可通过apt源直接获取。安装前需确保系统已启用main和universe源,并更新本地包索引。
1、打开终端,执行命令更新软件包列表:
sudo apt update
2、安装snapd服务(Certbot推荐使用snap版本以保证长期自动更新):
sudo apt install snapd
3、重启snapd守护进程并启用core snap:
sudo systemctl enable --now snapd.socket
sudo snap install core; sudo snap refresh core
4、安装certbot snap包并创建符号链接:
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
二、通过Certbot自动获取并配置SSL证书
该方法适用于已运行Nginx或Apache且域名已正确解析至本机IP的场景。Certbot可自动检测服务配置、暂停服务、验证域名所有权并写入证书。
1、确认Web服务正在运行且监听80端口:
sudo systemctl status nginx # 或 apache2
2、执行自动证书获取与安装命令(以Nginx为例):
sudo certbot --nginx -d your-domain.com -d www.your-domain.com
3、按提示输入邮箱地址用于紧急通知,并同意Let's Encrypt服务条款。
4、Certbot将自动修改Nginx配置文件,添加SSL监听、证书路径及重定向规则。
三、手动方式申请证书(不自动修改Web服务器配置)
当Web服务未被Certbot识别,或需自定义配置时,可采用standalone模式独立验证。此方式要求80或443端口临时由Certbot独占使用。
1、停止Nginx或Apache服务:
sudo systemctl stop nginx # 或 apache2
2、运行standalone验证命令:
sudo certbot certonly --standalone -d your-domain.com
3、验证成功后,证书文件将保存在:
/etc/letsencrypt/live/your-domain.com/fullchain.pem
私钥路径为:
/etc/letsencrypt/live/your-domain.com/privkey.pem
4、手动编辑Nginx或Apache配置,加载上述证书路径,并重启服务。
四、配置自动续期任务
Certbot证书有效期为90天,需定期续订。snap安装的certbot已内置定时器,但仍需验证其是否启用并测试续订流程。
1、检查certbot.timer状态:
sudo systemctl status snap.certbot.renew.timer
2、若未启用,执行启用命令:
sudo systemctl enable --now snap.certbot.renew.timer
3、手动触发一次续订测试(不实际更新证书):
sudo certbot renew --dry-run
4、若输出包含**The dry run was successful.**,说明续期机制正常工作。
五、验证证书部署效果
证书生效后,需确认浏览器可正确加载HTTPS页面,且无安全警告。同时检查证书链完整性与协议支持情况。
1、在浏览器中访问 https://your-domain.com,查看地址栏锁形图标是否显示为“安全”。
2、点击锁图标 → 查看证书 → 确认颁发者为 R3,有效期起止时间正确。
3、使用在线工具如 https://www.ssllabs.com/ssltest/ 输入域名进行深度检测。










