Skip to main content

Certbot DNS 阿里云 ESA 插件

通过阿里云边缘安全加速(ESA)API 自动创建 TXT 记录,完成 Certbot DNS-01 验证,申请及续期普通域名和泛域名证书。

本插件适用于 NS 接入 ESA 的域名,且 NS 委派须已生效;CNAME 接入仍需使用原 DNS 服务商的 Certbot 插件。参见 ESA DNS 接入方式。

功能特性

  • 自动分页查询站点,按 DNS 标签边界选择最长匹配项,无需手动填写站点 ID
  • 支持普通域名、子域名、泛域名及国际化域名
  • 支持多个挑战共用记录名,仅清理本次创建的记录,保留已有 TXT 记录
  • 支持 AccessKey 和 STS 临时凭证
  • 支持 Certbot 3、4、5 和 Python 3.9–3.15

Python 3.9 支持 Certbot 3/4,Python 3.10–3.13 支持 Certbot 3/4/5,Python 3.14–3.15 支持 Certbot 4/5。使用 Certbot 3 时需额外安装 pyopenssl<25。

安装

在实际运行 Certbot 的 Python 环境中,从 PyPI 安装:

pip install certbot-dns-esa

也可在项目源码目录中安装:

pip install .

安装后检查插件是否可用:

certbot plugins --text

输出应包含 dns-esa。使用 Certbot 3 时执行 pip install 'pyopenssl<25'。

配置文件

保存为 ~/esa.ini:

dns_esa_access_key_id = YOUR_ACCESS_KEY_ID
dns_esa_access_key_secret = YOUR_ACCESS_KEY_SECRET
# 可选,默认 cn-hangzhou;国际站可使用 ap-southeast-1
dns_esa_region_id = cn-hangzhou
# 可选,仅使用 STS 临时凭证时填写
# dns_esa_security_token = YOUR_SECURITY_TOKEN

region_id 应与站点所在的 API 地域一致。插件只查询所选地域,不会跨地域猜测。支持的公网接入点为杭州和新加坡,参见 ESA 服务接入点。使用 STS 时,续期前需确保凭证仍有效。

限制凭证文件权限:

chmod 600 ~/esa.ini

Windows 用户请通过系统文件权限限制访问。

运行

certbot certonly \
  --authenticator dns-esa \
  --dns-esa-credentials ~/esa.ini \
  --dns-esa-propagation-seconds 30 \
  -d '*.example.com' \
  -d example.com

DNS 传播等待默认 30 秒,可根据实际情况增加。TXT TTL 默认 600 秒,可通过 --dns-esa-ttl 调整;1 表示 ESA 自动 TTL,其余允许值取决于服务限制。创建记录超时后插件不会自动重试写入,以避免重复创建。

后续使用 certbot renew 自动续期。可先使用 certbot renew --dry-run 检查续期配置。

阿里云权限配置

AccessKey 需具备 AliyunESAFullAccess,或包含以下操作的自定义 RAM 权限:

{
  "Version": "1",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "esa:ListSites",
        "esa:ListRecords",
        "esa:CreateRecord",
        "esa:DeleteRecord"
      ],
      "Resource": "*"
    }
  ]
}

ListSites 和 DeleteRecord 需要 Resource: "*";ListRecords 和 CreateRecord 可进一步限制到指定站点。参见 ListSites、ListRecords、CreateRecord、DeleteRecord。

自动部署

本项目只负责 Certbot DNS 验证;申请后的自动部署可配合 AutoCert。

Metadata

Release files for certbot-dns-esa 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for certbot-dns-esa 1.0.2
File Size Uploaded Provenance Actions
certbot_dns_esa-1.0.2.tar.gz 281.8 kB With provenance Details for certbot_dns_esa-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for certbot-dns-esa 1.0.2
File Interpreter ABI Platform Actions
certbot_dns_esa-1.0.2-py3-none-any.whl Python 3 none any Details for certbot_dns_esa-1.0.2-py3-none-any.whl

Total release size: 291.9 kB

Release files / certbot_dns_esa-1.0.2.tar.gz

Download URL certbot_dns_esa-1.0.2.tar.gz
Size 281.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4aae64635eff177268cda56b5be197c53ecde347fee9fc4cbdba73b8cebaffc6
BLAKE2b-256 checksum
How to use checksums
48c0d957f858ddef233d7dcb6186dff6828864a8d281aa55c5f77051fc27ed3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / certbot_dns_esa-1.0.2-py3-none-any.whl

Download URL certbot_dns_esa-1.0.2-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1d4ad922fd68947b1c1cc4714f246d21329252c581400f4de98028b07dd7b7bf
BLAKE2b-256 checksum
How to use checksums
8a9f6c2b0afe505849918cb74866c8b3fb813afa6c017902d1ea5d5de17e1d18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Security for certbot-dns-esa 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for certbot_dns_esa-1.0.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page