如何将域添加到 Let's Encrypt/Certbot 生成的现有证书?

Mik*_*din 7 ssl ssl-certificate letsencrypt certbot

这个问题是本质上相同的问题的延续,该问题因在 Stack Overflow 上“偏离主题”而被关闭。OP的问题:

我只是想将域添加test.example.com到已经存在的证书中example.com。如何将域添加到我现有的证书并替换旧证书?

Mik*_*din 15

随着certbot 0.34.0,手续简单,方便(根据您的系统,替代certbot-auto~/certbot-autocertbot):

首先,列出您现有的证书和域:

sudo certbot certificates
Run Code Online (Sandbox Code Playgroud)

这将返回您的证书名称和当前证书上的域,例如:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
找到以下证书:证书名称:foo。 example.com
域:foo.example.com bar.example.com
到期日期:2119-08-01 11:30:32+00:00(有效:89 天)
证书路径:/etc/letsencrypt/live/foo。 example.com/fullchain.pem
私钥路径:/etc/letsencrypt/live/foo.example.com/privkey.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

然后在上面的 Domains: 行之后列出的域之间添加逗号,添加另一个逗号,以及您要添加的域,例如添加 baz.example.com:

sudo certbot --expand -d foo.example.com,bar.example.com,baz.example.com
Run Code Online (Sandbox Code Playgroud)