AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 750902
Accepted
Pierre Prinetti
Pierre Prinetti
Asked: 2016-01-22 14:13:47 +0800 CST2016-01-22 14:13:47 +0800 CST 2016-01-22 14:13:47 +0800 CST

如何使用 Let's Encrypt DNS 质询验证?

  • 772

Let's Encrypt宣布他们有:

开启对 ACME DNS 质询的支持

如何./letsencrypt-auto使用 DNS 质询域验证生成新证书?

编辑
我的意思是:我如何避免http/https端口绑定,通过使用新宣布的功能 (2015-01-20),您可以通过在目标域的 DNS 区域中添加特定的 TXT 记录来证明域所有权?

lets-encrypt
  • 10 10 个回答
  • 482748 Views

10 个回答

  • Voted
  1. Best Answer
    ph4r05
    2016-10-30T05:00:07+08:002016-10-30T05:00:07+08:00

    目前可以执行 DNS 验证,也可以在手动模式下使用certbot LetsEncrypt 客户端。自动化也是可能的(见下文)。

    手动插件

    您可以使用手动插件执行手动验证。

    certbot -d bristol3.pki.enigmabridge.com --manual --preferred-challenges dns certonly
    

    然后,Certbot 将向您提供手动更新域的 TXT 记录以继续验证的说明。

    Please deploy a DNS TXT record under the name
    _acme-challenge.bristol3.pki.enigmabridge.com with the following value:
    
    667drNmQL3vX6bu8YZlgy0wKNBlCny8yrjF1lSaUndc
    
    Once this is deployed,
    Press ENTER to continue
    

    更新 DNS 记录后,按 Enter,certbot 将继续,如果 LetsEncrypt CA 验证了质询,则照常颁发证书。

    您还可以使用具有更多选项的命令来最小化交互性和回答 certbot 问题。请注意,手动插件尚不支持非交互模式。

    certbot --text --agree-tos --email [email protected] -d bristol3.pki.enigmabridge.com --manual --preferred-challenges dns --expand --renew-by-default  --manual-public-ip-logging-ok certonly
    

    更新不适用于手动插件,因为它在非交互模式下运行。官方 certbot文档中的更多信息。

    更新:手动挂钩

    在新的 certbot 版本中,您可以使用钩子,例如--manual-auth-hook, --manual-cleanup-hook。挂钩是由 certbot 执行以执行任务的外部脚本。

    信息在环境变量中传递——例如,要验证的域、质询令牌。变量:CERTBOT_DOMAIN, CERTBOT_VALIDATION, CERTBOT_TOKEN.

    certbot certonly --manual --preferred-challenges=dns --manual-auth-hook /path/to/dns/authenticator.sh --manual-cleanup-hook /path/to/dns/cleanup.sh -d secure.example.com
    

    您可以编写自己的处理程序或使用现有的处理程序。有很多可用的,例如 Cloudflare DNS。

    有关官方 certbot hooks 文档的更多信息。

    自动化、更新、脚本

    如果您想自动化 DNS 质询验证,目前无法使用 vanilla certbot。更新:使用 certbot 钩子可以实现一些自动化。

    因此,我们创建了一个支持 DNS 自动化脚本的简单插件。它以certbot-external-auth的形式提供。

    pip install certbot-external-auth
    

    它支持 DNS、HTTP、TLS-SNI 验证方法。您可以在处理程序模式或 JSON 输出模式下使用它。

    处理程序模式

    在处理程序模式下,certbot + 插件调用外部挂钩(程序、shell 脚本、Python 等)来执行验证和安装。在实践中,您编写一个简单的处理程序/shell 脚本来获取输入参数 - 域、令牌并在 DNS 中进行更改。处理程序完成后,certbot 照常进行验证。

    这为您提供了额外的灵活性,也可以续订。

    处理程序模式还与脱水DNS 挂钩(以前的letsencrypt.sh)兼容。已经有许多用于常见提供商的 DNS 挂钩(例如,CloudFlare、GoDaddy、AWS)。在存储库中有一个自述文件,其中包含大量示例和示例处理程序。

    脱水DNS 挂钩的示例:

    certbot \
        --text --agree-tos --email [email protected] \
        --expand --renew-by-default \
        --configurator certbot-external-auth:out \
        --certbot-external-auth:out-public-ip-logging-ok \
        -d "bristol3.pki.enigmabridge.com" \
        --preferred-challenges dns \
        --certbot-external-auth:out-handler ./dehydrated-example.sh \
        --certbot-external-auth:out-dehydrated-dns \
        run 
    

    JSON模式

    另一种插件模式是 JSON 模式。它每行生成一个 JSON 对象。这可以实现更复杂的集成——例如,当 Ansible 或某些部署管理器调用 certbot 时。通过 STDOUT 和 STDIN 进行通信。Cerbot 生成带有数据的 JSON 对象以执行验证,例如:

    certbot \
        --text --agree-tos --email [email protected] \
        --expand --renew-by-default \
        --configurator certbot-external-auth:out \
        --certbot-external-auth:out-public-ip-logging-ok \
        -d "bristol3.pki.enigmabridge.com" \
        --preferred-challenges dns \
        certonly 2>/dev/null
    
    {"cmd": "perform_challenge", "type": "dns-01", "domain": "bs3.pki.enigmabridge.com", "token": "3gJ87yANDpmuuKVL2ktfQ0_qURQ3mN0IfqgbTU_AGS4", "validation": "ejEDZXYEeYHUxqBAiX4csh8GKkeVX7utK6BBOBshZ1Y", "txt_domain": "_acme-challenge.bs3.pki.enigmabridge.com", "key_auth": "3gJ87yANDpmuuKVL2ktfQ0_qURQ3mN0IfqgbTU_AGS4.tRQM98JsABZRm5-NiotcgD212RAUPPbyeDP30Ob_7-0"}
    

    DNS 更新后,调用者会将换行符发送到 certbot 的 STDIN,以表明它可以继续验证。

    这可以从中央管理服务器实现自动化和证书管理。对于安装,您可以通过 SSH 部署证书。

    有关更多信息,请参阅certbot-external-auth GitHub 上的自述文件和示例。

    编辑:还有一篇新的博客文章描述了 DNS 验证问题和插件的使用。

    编辑:我们目前正在研究 Ansible 两步验证,很快就会关闭。

    • 309
  2. alexcline
    2016-02-19T13:45:26+08:002016-02-19T13:45:26+08:00

    我能够使用dehydrated客户端通过 DNS 验证获取证书。

    https://github.com/lukas2511/dehydrad

    ./dehydrated --cron --domain my.domain.example.com --hook ./hook.route53.rb --challenge dns-01
    

    您需要为您的域使用正确的 DNS 验证挂钩,但有几个选项可用作示例:

    https://github.com/lukas2511/dehydrad/wiki/Examples-for-DNS-01-hooks

    • 45
  3. Simone Carletti
    2016-01-29T03:34:49+08:002016-01-29T03:34:49+08:00

    截至今天,官方客户端不支持 DNS-01 挑战类型(尚)。

    请参阅https://community.letsencrypt.org/t/status-of-official-letsencrypt-clients-dns-01-challenge-support/9427

    我没看过这个所以我真的不知道。我的高级理解只是“我们的 Python 客户端尚不支持 DNS 挑战”。

    您可以在此 PR上关注进度。或者,有一些客户端已经支持它。

    • 11
  4. J Jones
    2016-05-23T08:55:26+08:002016-05-23T08:55:26+08:00

    我为letsencrypt.sh客户端编写了一个钩子脚本,允许您对不提供使用api的DNS提供商使用Lets Encrypt DNS验证(也就是需要手动输入和验证)。

    你可以在这里查看:https ://github.com/jbjonesjr/letsencrypt-manual-hook

    • 5
  5. panticz
    2016-12-17T02:36:42+08:002016-12-17T02:36:42+08:00

    如前面的答案所述,您可以通过 DNS 轻松验证域:

    1. 安装所需的应用程序(在 Ubuntu 下): apt-get install -y git ruby letsencrypt git clone https://github.com/lukas2511/dehydrated.git git clone https://github.com/jbjonesjr/letsencrypt-manual-hook.git dehydrated/hooks/manual
    2. 为 www.example.com 生成带有手动 DNS 质询确认的证书(替换为您的域): ./dehydrated/dehydrated -c -t dns-01 -d www.example.com -k ./dehydrated/hooks /manual/manual_hook.rb
    • 3
  6. vikas027
    2018-02-03T05:44:24+08:002018-02-03T05:44:24+08:00

    在尝试了不同的组合之后,这就是我使用脱水和letsencrypt-manual-hook git存储库的方法。如果以下步骤对您有用,请不要忘记为这些存储库加注星标

    注意:这是 panticz.de 和 alexcline 答案的补充

    ~$ git clone https://github.com/lukas2511/dehydrated.git
    ~$ git clone https://github.com/jbjonesjr/letsencrypt-manual-hook.git dehydrated/hooks/manual
    ~$ cd dehydrated
    ~$ ./dehydrated --register --accept-terms
    ~$ ./dehydrated --cron --challenge dns-01 --domain your.domain.com --hook ./hooks/manual/manual_hook.rb
    #
    # !! WARNING !! No main config file found, using default config!
    #
    Processing your.domain.com
     + Signing domains...
     + Creating new directory /Users/vikas/dehydrated/certs/your.domain.com ...
     + Creating chain cache directory /Users/vikas/dehydrated/chains
     + Generating private key...
     + Generating signing request...
     + Requesting authorization for your.domain.com...
     + 1 pending challenge(s)
     + Deploying challenge tokens...
    Checking for pre-existing TXT record for the domain: '_acme-challenge.your.domain.com'.
    Create TXT record for the domain: '_acme-challenge.your.domain.com'. TXT record:
    'gkIxxxxxxxIcAESmjF8pjZGQrrZxxxxxxxxxxx'
    Press enter when DNS has been updated...
    

    您将获得一个哈希(运行上述命令后),在您的 DNS 中创建一个TXT记录。通过运行以下命令或GSuite Toolbox确保它正常工作

    ~$ dig TXT _acme-challenge.your.domain.com. +short @8.8.8.8
    "gkIxxxxxxxIcAESmjF8pjZGQrrZxxxxxxxxxxx"
    ~$
    

    现在,在提示符下按回车。尽管更新了 TXT 记录,但这对我不起作用。我不得不按 Ctrl+C 并再次运行该命令。

    ~$ ./dehydrated --cron --challenge dns-01 --domain your.domain.com --hook ./hooks/manual/manual_hook.rb
    #
    # !! WARNING !! No main config file found, using default config!
    #
    Processing your.domain.com
     + Signing domains...
     + Generating private key...
     + Generating signing request...
     + Requesting authorization for your.domain.com...
     + 1 pending challenge(s)
     + Deploying challenge tokens...
    Checking for pre-existing TXT record for the domain: '_acme-challenge.your.domain.com'.
    Found gkIxxxxxxxIcAESmjF8pjZGQrrZxxxxxxxxxxx. match.
     + Responding to challenge for your.domain.com authorization...
    Challenge complete. Leave TXT record in place to allow easier future refreshes.
     + Challenge is valid!
     + Requesting certificate...
     + Checking certificate...
     + Done!
     + Creating fullchain.pem...
     + Walking chain...
     + Done!
    ~$
    

    现在,您的公共和私人证书都在这里。

    $ ls certs/your.domain.com/privkey.pem certs/your.domain.com/fullchain-1517576424.pem
    

    要续订(最短等待时间为 30 天),只需再次执行相同的命令。

    ~$ ./dehydrated --cron --challenge dns-01 --domain your.domain.com --hook ./hooks/manual/manual_hook.rb
    
    • 3
  7. karlsebal
    2019-10-31T07:29:19+08:002019-10-31T07:29:19+08:00

    在certbot--manual-auth-hook中使用时很容易完成。--manual-cleanup-hook

    certbot-auto --manual --preferred-challenges dns --manual-auth-hook auth.sh --manual-cleanup-hook cleanup.sh -d your.domain.com -d *.wildcard.domains.com`
    

    在哪里auth.sh会像

    #!/bin/sh
    
    KEYFILE=tsig_key_file
    
    nsupdate -k $KEYFILE <<EOT
    server ns.some-domain.com
    update add _acme-challenge.$CERTBOT_DOMAIN 60 txt $CERTBOT_VALIDATION
    send
    EOT
    
    # wait a few seconds to let the change take effect
    sleep 5
    

    和cleanup.sh类似的东西

    #!/bin/sh
    
    KEYFILE=/opt/certbot-authenticator/tsig
    
    nsupdate -k $KEYFILE<<EOT
    server dns-master
    update del _acme-challenge.$CERTBOT_DOMAIN
    send
    EOT
    

    前提是您的 dns 服务器已正确配置为允许动态 dns 更新 (RFC2136)。强烈建议使用 TSIG 密钥,但如果您选择不使用它,只需-k $KEYFILE在调用nsupdate.

    • 2
  8. Harald
    2018-07-04T10:07:10+08:002018-07-04T10:07:10+08:00

    Hugo Landau 在 Go ( https://github.com/hlandau/acme ) 中编写了一个支持 DNS 挑战的 ACME 客户端(使用 BIND 的 nsupdate 协议)。至少 18 个月以来,它一直完美地为我工作。

    • 1
  9. Константин Ван
    2021-06-13T05:30:09+08:002021-06-13T05:30:09+08:00

    也许使用certbot的 DNS 插件之一?

    此类插件通过修改 DNS 记录来自动获取证书,以证明您对域具有控制权。以这种方式进行域验证是从 Let's Encrypt 获取通配符证书的唯一方法。

    • 0
  10. Sam
    2022-09-07T07:55:55+08:002022-09-07T07:55:55+08:00

    对于 macOS

    brew install certbot
    
    sudo certbot certonly --manual --preferred-challenges dns -d "domain.com" -d "www.domain.com"
    
    • 0

相关问题

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve