【问题标题】:Automated way to add a alternative name to a letsencrypt Cert向letsencrypt证书添加替代名称的自动化方法
【发布时间】:2021-01-26 00:05:43
【问题描述】:

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

我要加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
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

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

hz1:/etc/apache2# certbot certonly --cert-name hz1.yz.to -d hz1.yz.to,thomas-guettler.de,erzgebirgstraverse.de

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

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): 
systemctl reload apache2

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

【问题讨论】:

  • 你试过 -n 标志来运行非交互吗?

标签: ssl lets-encrypt


【解决方案1】:

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

要跳过此安装步骤,只需使用certbot certonly ... 子命令。根据the CLI manpagesObtain 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

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

  1. Apache Web 服务器插件 (apache) -> certbot 将创建 apache 设置,因此 HTTP 质询可用于验证域实际上与您的服务器相关联
  2. 启动临时网络服务器(独立)-> Certbot 将运行自己的网络服务器来执行 HTTP 质询。这只有在没有其他网络服务器在端口 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 不是唯一可用于生成证书的加密客户端。有很多可用的客户:https://letsencrypt.org/docs/client-options/

【讨论】:

  • 感谢您提供与其他客户的链接。到目前为止,我认为certbot 是唯一的方法。
【解决方案2】:

您至少需要:--non-interactive--agree-tos-m 'you@your-email.com'。这将允许 certbot 无需任何交互即可运行。

此外,指定--nginx--apache 如果适合您的配置(未指定这是什么网络服务器类型)或certonly --manual 如果您实际上只需要证书,可能会很有用。

一个完成的命令示例(假设这里是 nginx)是:certbot --nginx --non-interactive --agree-tos -m 'you@your-email.com' -d 'erzgebirgstraverse.de'

请注意,所有这些都在https://certbot.eff.org/docs/using.html 中指定(以某种迂回的方式)

【讨论】:

    猜你喜欢
    • 2020-02-20
    • 2012-02-03
    • 2017-05-14
    • 2023-03-21
    • 2019-11-14
    • 1970-01-01
    • 2017-03-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多