Certbot DNS 认证申请 SSL 证书

使用 Certbot 生成证书

运行以下命令来启动手动 DNS 认证流程:

1sudo certbot certonly --manual --preferred-challenges=dns -d example.com -d *.example.com
  • certonly: 仅获取证书,而不会自动配置 Web 服务器。

  • --manual: 选择手动验证模式。

  • --preferred-challenges=dns: 指定使用 DNS 方式进行验证。

  • -d example.com -d *.example.com: 申请该域名和通配符域名的证书。

添加 DNS TXT 记录

执行上述命令后,Certbot 会输出类似以下的信息:

1Please deploy a DNS TXT record under the name
2_acme-challenge.example.com with the following value:
3
4XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5
6Before continuing, verify the record is deployed.

你需要登录到域名注册商或 DNS 服务提供商的管理控制台,手动添加一个 TXT 记录:

  • 主机记录(Host/Name): _acme-challenge.example.com

  • 记录类型(Type): TXT

  • 记录值(Value): Certbot 提供的 XXXXXXXXXXXXXXXXXXXXXXXXX

等待 DNS 记录生效

可以使用以下命令来检查 DNS 记录是否已生效:

1nslookup -q=txt _acme-challenge.example.com
使用 Hugo 构建
主题 StackJimmy 设计