我有多个域名和多个证书:
$ ll /etc/letsencrypt/live/
> domain1.com
> domain2.com
> domain3.com
> ...
我只需要更新 domain1.com
的证书,但命令 certbot renew
会为所有域名更新证书。如何显式地更新特定证书?
我有多个域名和多个证书:
$ ll /etc/letsencrypt/live/
> domain1.com
> domain2.com
> domain3.com
> ...
我只需要更新 domain1.com
的证书,但命令 certbot renew
会为所有域名更新证书。如何显式地更新特定证书?
使用renew
命令和--cert-name
选项来更新单个证书。
(certonly
为一个或多个域创建证书,如已存在则替换原证书)。
certbot renew --cert-name domain1.com --dry-run
要实际更新,请删除--dry-run
。
请注意,提供给--cert-name
选项的值是证书名称(不是域名),可以使用以下内容找到:
certbot certificates
返回像这样的列表
-------------------------------------------------------------------------------
Found the following certs:
Certificate Name: myfundomains.com
Domains: myfundomains.com
Expiry Date: 2018-05-04 04:28:05+00:00 (VALID: 67 days)
Certificate Path: /etc/letsencrypt/live/myfundomains.com/fullchain.pem
Private Key Path: /etc/letsencrypt/live/myfundomains.com/privkey.pem
Certificate Name: ask.myfundomain.com
Domains: ask.myfundomain.com
Expiry Date: 2018-03-13 18:59:40+00:00 (VALID: 16 days)
Certificate Path: /etc/letsencrypt/live/ask.myfundomain.com/fullchain.pem
Private Key Path: /etc/letsencrypt/live/ask.myfundomain.com/privkey.pem
Certificate Name: forums.myfundomain.com
Domains: forums.myfundomain.com forum.myfundomain.com
Expiry Date: 2018-04-11 16:39:18+00:00 (VALID: 45 days)
Certificate Path: /etc/letsencrypt/live/forums.myfundomain.com/fullchain.pem
Private Key Path: /etc/letsencrypt/live/forums.myfundomain.com/privkey.pem
-------------------------------------------------------------------------------
请注意第三个证书名称(forums.myfundomain.com)包含多个域名:
-------------------------------------------------------------------------------
new certificate deployed without reload, fullchain is
/etc/letsencrypt/live/ask.myfundomain.com/fullchain.pem
-------------------------------------------------------------------------------
记得重新启动你的 Web 服务器以使用新的证书。
你可以使用以下命令(适用于Apache服务器):
certbot --apache certonly -n -d domain1.com
--apache
指定使用 Apache 服务器,使用 --nginx
标志指定 Nginx 服务器-n
选项在不提示的情况下执行命令-d domain1.com
仅为 domain1.com 执行您可以使用 --dry-run
进行测试,并且您可以像使用 certbot renew
一样使用 --pre-hook
和 --post-hook
来源:https://certbot.eff.org/docs/using.html#renewing-certificates
您可以在Nginx服务器上使用以下命令:
停止Nginx服务器
sudo systemctl stop nginx
更新Certbot
sudo certbot certonly --force-renew -d domain1.com
启动Nginx服务器
sudo systemctl start nginx
检查当前证书
sudo certbot certificates
结果:
找到以下证书:证书名称:domain1.com 序列号:4564f55f3fe993964f8bbc65249a7ed4c91 密钥类型:RSA 域名:domain1.com 到期日期:2022-12-19 01:34:25+00:00(有效期89天) 证书路径:/etc/letsencrypt/live/domain1.com/fullchain.pem 私钥路径:/etc/letsencrypt/live/domain1.com/privkey.pem
sudo certbot -d domainname --expand
service nginx reload
就可以了 - 不需要重新启动。 - cybernet2u