Certbot Letencrypt Wildcardcertificates Alydns Au banner
zning1994 zning1994

Certbot Letencrypt Wildcardcertificates Alydns Au

Development community

Description

certbot renewing letencrypt certificate plugin - automatic verification aliyun/tencentyun/godaddy dns

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

[![996.icu](https://img.shields.io/badge/link-996.icu-red.svg)](https://996.icu) [![LICENSE](https://img.shields.io/badge/license-Anti%20996-blue.svg)](https://github.com/996icu/996.ICU/blob/master/LICENSE)

功能

使用 certbot 工具,为不能自动给 letencrypt 通配符证书自动续期(renew)而烦恼吗?这个工具能够帮忙!

不管是申请还是续期,只要是通配符证书,只能采用 dns-01 的方式校验申请者的域名,也就是说 certbot 操作者必须手动添加 DNS TXT 记录。

如果你编写一个 Cron (比如 1 1 */1 * * root certbot-auto renew),自动 renew 通配符证书,此时 Cron 无法自动添加 TXT 记录,这样 renew 操作就会失败,如何解决?

certbot 提供了一个 hook,可以编写一个 Shell 脚本,让脚本调用 DNS 服务商的 API 接口,动态添加 TXT 记录,这样就无需人工干预了。

在 certbot 官方提供的插件和 hook 例子中,都没有针对国内 DNS 服务器的样例,所以我编写了这样一个工具,目前支持阿里云 DNS、腾讯云 DNS、GoDaddy(certbot 官方没有对应的插件)。

自动申请通配符证书

1:下载

$ git clone https://github.com/ywdblog/certbot-letencrypt-wildcardcertificates-alydns-au

$ cd certbot-letencrypt-wildcardcertificates-alydns-au

$ chmod 0777 au.sh 

2:配置

(1)domain.ini

如果domain.ini文件没有你的根域名,请自行添加。

(2)DNS API 密钥:

这个 API 密钥什么意思呢?由于需要通过 API 操作阿里云 DNS 或腾讯云 DNS 的记录,所以需要去域名服务商哪儿获取 API 密钥,然后配置在 au.sh 文件中:

(3)选择运行环境

目前该工具支持五种运行环境和场景,通过 hook 文件和参数来调用:

  • PHP(>4以上版本均可)
    • au.sh php aly add/clean:PHP操作阿里云DNS,增加/清空DNS。
    • au.sh php txy add/clean:PHP操作腾讯云DNS,增加/清空DNS。
    • au.sh php godaddy add/clean:PHP操作GoDaddy DNS,增加/清空DNS。
  • Python(支持2.7和3.7,无需任何第三方库)
    • au.sh python aly add/clean:Python操作阿里云DNS,增加/清空DNS。
    • au.sh python txy add/clean:Python操作腾讯云DNS,增加/清空DNS。
    • au.sh python godaddy add/clean:Python操作GoDaddy DNS,增加/清空DNS。

根据自己服务器环境和域名服务商选择任意一个 hook shell(包含相应参数),具体使用见下面。

3:申请证书

测试是否有错误:

$ ./certbot-auto certonly  -d *.example.com --manual --preferred-challenges dns --dry-run  --manual-auth-hook "/脚本目录/au.sh php aly add" --manual-cleanup-hook "/脚本目录/au.sh php aly clean"