将替代名称添加到 LetsEncrypt 证书的自动方法

gue*_*tli 5 ssl lets-encrypt

我正在寻找一种自动添加新域的方法。

我想补充一下erzgebirgstraverse.de

来自https://certbot.eff.org/docs/using.html#changing-a-certificate-s-domains

...扩展证书包含的域集...

certbot certonly --cert-name example.com -d example.org,www.example.org

我找到了一种列出所有现有证书的方法:

hz1:/etc/apache2# certbot certificates
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Found the following certs:
  Certificate Name: hz1.yz.to
    Serial Number: 345a3c36ff032d325e78120c98d8ddc71f7
    Domains: hz1.yz.to thomas-guettler.de
    Expiry Date: 2021-03-23 09:19:00+00:00 (VALID: 80 days)
    Certificate Path: /etc/letsencrypt/live/hz1.yz.to/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/hz1.yz.to/privkey.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Run Code Online (Sandbox Code Playgroud)

现在我看到现有的域,并且可以添加erzgebirgstraverse.de标志-d

hz1:/etc/apache2# certbot certonly --cert-name hz1.yz.to -d hz1.yz.to,thomas-guettler.de,erzgebirgstraverse.de
Run Code Online (Sandbox Code Playgroud)

但现在交互式脚本开始了:

Saving debug log to /var/log/letsencrypt/letsencrypt.log

How would you like to authenticate with the ACME CA?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: Apache Web Server plugin (apache)
2: Spin up a temporary webserver (standalone)
3: Place files in webroot directory (webroot)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-3] then [enter] (press 'c' to cancel): 
Run Code Online (Sandbox Code Playgroud)
systemctl reload apache2
Run Code Online (Sandbox Code Playgroud)

有没有办法添加新域(替代名称)但非交互式

Ant*_*ane 7

默认情况下,Certbot 将尝试帮助您生成证书。此外,它还会提示您提供信息,以帮助在您的 Apache/Nginx 设置中安装它们。

要跳过此安装步骤,只需使用certbot certonly ...子命令即可。根据CLI 手册页Obtain or renew a certificate, but do not install it

或者,您可以使用该标志-n/--non-interactive来确保 certbot 将在不提示任何内容的情况下进行处理。在这种情况下,您必须确保所有需要的信息都通过命令行传递。特别是,您必须确保您已同意条款和条件 ( --agree-tos) 并提供了有效的联系电子邮件 ( -m email@domain)。例子:

certbot certonly --agree-tos -m contact&mydomain.com --cert-name hz1.yz.to -d hz1.yz.to,thomas-guettler.de,erzgebirgstraverse.de
Run Code Online (Sandbox Code Playgroud)

在您的问题中,系统会提示您输入身份验证方法。您必须了解,让我们加密必须验证您正在执行客户端的服务器可以正确地与您尝试生成证书的域关联。可用的方法有:

  1. Apache Web 服务器插件 (apache) -> certbot 将创建 apache 设置,以便可以使用 HTTP 质询来验证域实际上与您的服务器关联
  2. 启动临时网络服务器(独立)-> Certbot 将运行自己的网络服务器来执行 HTTP 质询。仅当没有其他 Web 服务器正在侦听端口 80 时(apache 和 nginx 将侦听该地址),此操作才有效。这个方法在大多数服务器上可能没用
  3. 将文件放入 webroot 目录 (webroot) -> 如果您已有 HTTP 服务器侦听端口 80,则可以指示 certbot 将文件放入 webroot 目录中,以便可以使用 HTTP 质询。

要从命令行预先选择 3 种可用方法之一(并避免交互式提示),请使用选项--apache(1)、--standalone(2) 或--webroot(3)。

请记住,HTTP 质询并不是验证服务器/域一致性的唯一解决方案。基于 DNS 和 TLS 的挑战可能非常有用: https: //letsencrypt.org/docs/challenge-types/我不确定 certbot 本身是否实现了此类挑战,但您可以找到可以实现的第三方插件。

此外,请认为 certbot 并不是唯一可用于生成证书的 Let's Encrypt 客户端。有很多可用的客户端: https: //letsencrypt.org/docs/client-options/