关键词
acme.sh 泛域名证书,阿里云 DNS 申请 SSL, 免费泛域名 SSL, Let’s Encrypt 国内申请,无需翻墙 SSL 证书,https 证书
最近在用k8s搭建服务,需要给 测试业务 申请一张泛域名 SSL 证书,实现 *.nextclouds.xxx 所有二级域名 HTTPS 访问。
本文使用 acme.sh + 阿里云 DNS 自动验证,全程国内环境、无需梯子,记录完整命令执行过程,可直接照搬。
环境说明
系统:CentOS 7
域名:nextclouds.xxx(阿里云 DNS)
工具:acme.sh
证书类型:泛域名 SSL(主域名 + 二级域名通用)
1. 安装 acme.sh(国内镜像,不翻墙)
GitHub 源国内访问超时,直接使用 Gitee 镜像安装:
wget -O acme.sh https://gitee.com/neilpang/acme.sh/raw/master/acme.sh
chmod +x acme.sh
./acme.sh --install-online --force
source ~/.bashrc
acme.sh -v执行输出:
[root@master01 yewuceshi]# wget -O acme.sh https://gitee.com/neilpang/acme.sh/raw/master/acme.sh
--2026-04-14 21:04:20-- https://gitee.com/neilpang/acme.sh/raw/master/acme.sh
正在解析主机 gitee.com (gitee.com)... 180.76.199.13, 180.76.198.77, 180.76.198.225
正在连接 gitee.com (gitee.com)|180.76.199.13|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:未指定 [text/plain]
正在保存至: “acme.sh”
acme.sh [ <=> ] 229.75K --.-KB/s 用时 0.1s
2026-04-14 21:04:20 (1.99 MB/s) - “acme.sh” 已保存 [235259]
[root@master01 yewuceshi]# chmod +x acme.sh
[root@master01 yewuceshi]# ./acme.sh --install-online --force
[2026年 04月 14日 星期二 21:04:21 CST] Installing from online archive.
[2026年 04月 14日 星期二 21:04:21 CST] Downloading https://github.com/acmesh-official/acme.sh/archive/master.tar.gz
[2026年 04月 14日 星期二 21:04:22 CST] Extracting master.tar.gz
[2026年 04月 14日 星期二 21:04:23 CST] Installing to /root/.acme.sh
[2026年 04月 14日 星期二 21:04:23 CST] Installed to /root/.acme.sh/acme.sh
[2026年 04月 14日 星期二 21:04:23 CST] Installing alias to '/root/.bashrc'
[2026年 04月 14日 星期二 21:04:23 CST] Close and reopen your terminal to start using acme.sh
[2026年 04月 14日 星期二 21:04:23 CST] Installing alias to '/root/.cshrc'
[2026年 04月 14日 星期二 21:04:23 CST] Installing alias to '/root/.tcshrc'
[2026年 04月 14日 星期二 21:04:23 CST] Installing cron job
17 7 * * * "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" > /dev/null
[2026年 04月 14日 星期二 21:04:23 CST] bash has been found. Changing the shebang to use bash as preferred.
[2026年 04月 14日 星期二 21:04:25 CST] OK
[2026年 04月 14日 星期二 21:04:25 CST] Install success!
[root@master01 yewuceshi]# source ~/.bashrc
[root@master01 yewuceshi]# acme.sh -v
https://github.com/acmesh-official/acme.sh
v3.1.32. 配置阿里云 API 密钥
export Ali_Key="你自己的阿里云KEY"
export Ali_Secret="你自己的阿里云Secret"3. 一键申请泛域名证书
acme.sh --issue \
--dns dns_ali \
-d nextclouds.xxx \
-d "*.nextclouds.xxx" \
--server letsencrypt完整执行输出(真实实录):
[2026年 04月 14日 星期二 21:14:55 CST] Using CA: https://acme-v02.api.letsencrypt.org/directory
[2026年 04月 14日 星期二 21:14:56 CST] Creating domain key
[2026年 04月 14日 星期二 21:14:56 CST] The domain key is here: /root/.acme.sh/nextclouds.xxx_ecc/nextclouds.xxx.key
[2026年 04月 14日 星期二 21:14:56 CST] Multi domain='DNS:nextclouds.xxx,DNS:*.nextclouds.xxx'
[2026年 04月 14日 星期二 21:14:59 CST] Getting webroot for domain='nextclouds.xxx'
[2026年 04月 14日 星期二 21:14:59 CST] Getting webroot for domain='*.nextclouds.xxx'
[2026年 04月 14日 星期二 21:15:00 CST] Adding TXT value: Z2bLXG5peRXqUITMI-AI3DHM02iKDPAGu6u7sUgMr7A for domain: _acme-challenge.nextclouds.xxx
[2026年 04月 14日 星期二 21:15:01 CST] The TXT record has been successfully added.
[2026年 04月 14日 星期二 21:15:01 CST] Adding TXT value: gavW7LSD4j6q-6c4cvHOvzNuVCkQMyFFOuCjQMrlEXs for domain: _acme-challenge.nextclouds.xxx
[2026年 04月 14日 星期二 21:15:03 CST] The TXT record has been successfully added.
[2026年 04月 14日 星期二 21:15:03 CST] Let's check each DNS record now. Sleeping for 20 seconds first.
[2026年 04月 14日 星期二 21:15:24 CST] You can use '--dnssleep' to disable public dns checks.
[2026年 04月 14日 星期二 21:15:24 CST] See: https://github.com/acmesh-official/acme.sh/wiki/dnscheck
[2026年 04月 14日 星期二 21:15:24 CST] Checking nextclouds.fun for _acme-challenge.nextclouds.xxx
[2026年 04月 14日 星期二 21:15:24 CST] Please refer to https://curl.haxx.se/libcurl/c/libcurl-errors.html for error code: 35
[2026年 04月 14日 星期二 21:15:32 CST] Please refer to https://curl.haxx.se/libcurl/c/libcurl-errors.html for error code: 28
[2026年 04月 14日 星期二 21:15:32 CST] Success for domain nextclouds.xxx '_acme-challenge.nextclouds.xxx'.
[2026年 04月 14日 星期二 21:15:32 CST] Checking nextclouds.fun for _acme-challenge.nextclouds.xxx
[2026年 04月 14日 星期二 21:15:32 CST] Success for domain nextclouds.xxx '_acme-challenge.nextclouds.xxx'.
[2026年 04月 14日 星期二 21:15:32 CST] All checks succeeded
[2026年 04月 14日 星期二 21:15:32 CST] Verifying: nextclouds.xxx
[2026年 04月 14日 星期二 21:15:33 CST] Pending. The CA is processing your order, please wait. (1/30)
[2026年 04月 14日 星期二 21:15:37 CST] Success
[2026年 04月 14日 星期二 21:15:37 CST] Verifying: *.nextclouds.xxx
[2026年 04月 14日 星期二 21:15:38 CST] Pending. The CA is processing your order, please wait. (1/30)
[2026年 04月 14日 星期二 21:15:42 CST] Success
[2026年 04月 14日 星期二 21:15:42 CST] Removing DNS records.
[2026年 04月 14日 星期二 21:15:42 CST] Removing txt: Z2bLXG5peRXqUITMI-AI3DHM02iKDPAGu6u7sUgMr7A for domain: _acme-challenge.nextclouds.xxx
[2026年 04月 14日 星期二 21:15:44 CST] Successfully removed
[2026年 04月 14日 星期二 21:15:44 CST] Removing txt: gavW7LSD4j6q-6c4cvHOvzNuVCkQMyFFOuCjQMrlEXs for domain: _acme-challenge.nextclouds.xxx
[2026年 04月 14日 星期二 21:15:45 CST] Successfully removed
[2026年 04月 14日 星期二 21:15:45 CST] Verification finished, beginning signing.
[2026年 04月 14日 星期二 21:15:46 CST] Let's finalize the order.
[2026年 04月 14日 星期二 21:15:46 CST] Le_OrderFinalize='https://acme-v02.api.letsencrypt.org/acme/finalize/3237888171/500619697271'
[2026年 04月 14日 星期二 21:15:48 CST] Downloading cert.
[2026年 04月 14日 星期二 21:15:48 CST] Le_LinkCert='https://acme-v02.api.letsencrypt.org/acme/cert/053dae171373e37085439da807b7f41f4d7e'
[2026年 04月 14日 星期二 21:15:49 CST] Cert success.
-----BEGIN CERTIFICATE-----
MIIDmzCCAyGgAwIBAgISBT2uFxNz43CFQ52oB7f0H01+MAoGCCqGSM49BAMDMDIx
CzAJBgNVBAYTAlVTMRxxxxYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQDEwJF
ODAeFw0yNjA0MTQxMjE3MTZaFw0yNjA3MTMxMjE3MTVaMBkxFzAVBgNVBAMTDm5l
eHRjbG91ZHMuZnVuMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE4U7ep055PbHC
kMQsSNRtAnrDlTcGw3wItmvWPpa1eZS+vNPmMMIl+Uw6ovtjXvrBrF4j7v0QUvaM
3UZ1KkkEZaOCAi4wggIqMA4GA1UdDwEB/wQEAwIHgDATBgNVHSUEDDAKBggrBgEF
BQcDATAMBgNVHRMBAf8EAjAAMB0GA1UdDgQWBBS1J0SBX3E/vcqS3E8lDMkDzJhR
bzAfBgNVHSMEGDAWgBSPDROi9i5+0VBsMxg4XVmOI3KRyjAyBggrBgEFBQcBAQQm
MCQwIgYIKwYBBQUHMAKGFmh0dHA6Ly9lOC5pLmxlbmNyLm9yZy8wKwYDVR0RBCQw
IoIQKi5uZXh0Y2xvdWRzLmZ1boIObmV4dGNsb3Vkcy5mdW4wEwYDVR0gBAwwCjAI
BgZngQwBAgEwLgYDVR0fBCcwJTAjoCGgH4YdaHR0cDovL2U4LmMubGVuY3Iub3Jn
LzEyNy5jcmwwggENBgorBgEEAdZ5AgQCBIH+BIH7APkAdgDLOPcViXyEoURfW8Hd
+8lu8ppZzUcKaQWFsMsUwxRY5wAAAZ2MIjtdAAAEAwBHMEUCIQChql7Yrxkq1D7b
YpxVeaKdFSfntKBiXuvlYu/nqOMJcAIgIflEDFrBUT2Sq/IXJvipwLOelwMEOmZs
4Z5o60VM4G4AfwAai51rD/6/gbR5OcbSMQqG1tEC1PBG4hgsneNfXiYl7wAAAZ2M
Ij51AAgAAAUACRSjuQQDAEgwRgIhAOLAoJ7bFEtvx2o7FVg9nOpXSjlOYGDGlxIT
p7QlNHc4AiEAuBNP37MqvvHuDL1dcSiuzVE+d8Exy6P8iD6DaYUFkcMwCgYIKoZI
zj0EAwMDaAAwZQIwZ/xx/xxxx/kBBneZ4tpfE3yVWFVrl1yW7MjlWPwkA4eeSN6T
9sXzXdZhgOD87MnAAjEAztE8zqICcGUVKA4LPms9Fd2slnp8JYcg3UUKXEapTY7f
+ouBtynpAD8MsoIkyPKp
-----END CERTIFICATE-----
[2026年 04月 14日 星期二 21:15:49 CST] Your cert is in: /root/.acme.sh/nextclouds.xxx_ecc/nextclouds.xxx.cer
[2026年 04月 14日 星期二 21:15:49 CST] Your cert key is in: /root/.acme.sh/nextclouds.xxx_ecc/nextclouds.xxx.key
[2026年 04月 14日 星期二 21:15:49 CST] The intermediate CA cert is in: /root/.acme.sh/nextclouds.xxx_ecc/ca.cer
[2026年 04月 14日 星期二 21:15:49 CST] And the full-chain cert is in: /root/.acme.sh/nextclouds.xxx_ecc/fullchain.cer4. 证书文件位置
/root/.acme.sh/nextclouds.xxx_ecc/fullchain.cer → 部署用证书链
nextclouds.xxx.key → 私钥
nextclouds.xxx.cer → 域名证书
5. 自动续期
acme.sh 会自动添加 crontab 定时任务,90 天自动续期,无需人工干预。
6. 解析设置
记得在阿里云DNS解析控制台添加泛域名解析记录。

总结
这套方案适合:
NextCloud / NAS / 群晖
爱快路由 / 内网穿透
个人博客 / 多个二级域名
国内服务器、无翻墙环境
全程一键自动化,无需手动添加 TXT 记录,非常适合生产环境使用。
评论区