使用 certbot 和使用 DNS 质询更新域

Mer*_*erc 14 lets-encrypt certbot

我使用独立方法为多个域创建了多个 SSL 证书。我只对证书感兴趣,没有服务器集成。

他们现在正在更新。所以,我跑了:

certbot -d example.com --manual --preferred-challenges dns certonly
Run Code Online (Sandbox Code Playgroud)

并遵循每个域的说明(为每个域添加所需的 DNS 条目)。这样,我不必停止服务器并获得我的新证书。

我对这一切的(模糊)理解是,目前没有使用 DNS 质询自动更新证书的方法。或者您可能无法为“手动”方法自动更新证书?

无论如何,我写了这个脚本:

#!/bin/bash

for i in renewal/*;do
  n=${i:8:-5};
  echo $n;
  # echo "\n" | certbot --text --agree-tos -d $n --manual --preferred-challenges dns --expand --renew-by-default  --manual-public-ip-logging-ok certonly;
done
Run Code Online (Sandbox Code Playgroud)

此时,在renewal目录中所有域都有:

验证器 = 手册

和:

pref_challs = dns-01
Run Code Online (Sandbox Code Playgroud)

问题:

  • 现在......当我运行“certbotrenew”时,它会在不使用我的脚本的情况下自动更新所有这些吗?

  • 如何开始使用 DNS 质询实际创建新证书?

小智 11

更新的答案(见下面的原始答案)

在我的原始答案中,我关注的是使用renew命令时不需要您提供的脚本这一事实。但是,我并不确定该renew命令是否真的适用于这种情况。

正如评论中的 cdhowie 和 bobpaul 所述:certbot renew是一种非交互模式 - 结合 dns 挑战 - 要求您通过--manual-auth-hook参数提供脚本。所述脚本必须能够设置TXT记录。您还可以提供另一个脚本以通过--manual-cleanup-hook参数进行清理。

如果您提供这些参数,则整个过程将自动运行,无需任何交互。

如果您不提供这些参数,certbot 将失败:

/opt/certbot # certbot renew --force-renewal
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/foobar.w9f.de.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Could not choose appropriate plugin: The manual plugin is not working; there may be problems with your existing configuration.
The error was: PluginError('An authentication script must be provided with --manual-auth-hook when using the manual plugin non-interactively.',)
Run Code Online (Sandbox Code Playgroud)

如果要通过手动模式更新证书,则必须重新运行用于获取证书的命令。在这种情况下,您的脚本是一个不错的选择,因为该certonly命令不会查看当前的证书/配置,而是要求您通过-d参数或以交互模式提供域名。


当我运行“certbotrenew”时,它会在不使用我的脚本的情况下自动更新所有这些吗?

TL;DR:是的,它应该。

让我们看看certbot文档

从 0.10.0 版本开始,Certbot 支持更新操作以检查所有已安装的证书是否即将到期并尝试更新它们。最简单的形式就是

certbot更新

到现在为止还挺好。

此命令尝试更新任何先前获得的在 30 天内到期的证书。

这应该回答你的问题。当心:我不知道如何certbot处理将证书移动到不同目录的情况。

在同一段的后面:

除非您指定其他插件或选项,否则最初颁发证书时使用的相同插件和选项将用于续订尝试。与 不同certonlyrenew作用于多个证书并始终考虑每个证书是否即将到期。

所以,是的;certbot应该在没有脚本帮助的情况下更新所有证书。


如何开始使用 DNS 质询实际创建新证书?

您在帖子开头发布的命令有什么问题? certbot -d example.com --manual --preferred-challenges dns certonly将使用 dns 质询获取 example.com 的证书。

创建证书的步骤是:

  • 运行certbot你发布的命令
  • 等待命令显示 DNS TXT 记录
  • 创建该 TXT 记录
  • 继续certbot命令
  • 获取指定域的证书
  • 删除 TXT 记录(因为你只需要它来创建和一个新的更新)

如果你想自动化整个过程,你可能想看看像乐高这样支持几个DNS 提供商的工具

  • 这个答案是不正确的。[`certbot refresh` 不支持没有脚本的手动方法](https://community.letsencrypt.org/t/certbot-auto-renew-failure-and-now-domain-needs-renewal/63045)。 (4认同)