SSL证书

Let’s Encrypt Wildcard 免费泛域名SSL证书一键申请与SSL使用教程

Let’s Encrypt 的泛域名证书适合子域名比较多的站点。证书用 DNS-01 验证,所以签发的机器不必对公网开放 80 端口。申请、部署和续期可以分开做。

Let’s Encrypt的单域名SSL证书极大的推动了SSL证书在世界范围内的普及,而现在更加让人兴奋的消息是:经过无数次的跳票,Let’s Encrypt Wildcard 免费泛域名SSL证书终于上线了!任何个人都是可以免费申请,利用脚本Acme.sh可以实现一键签发,十分方便。

用 acme.sh 可以把签发、部署和续期连起来。证书有效期取决于所选配置,按实际到期时间核对,别把旧文的三个月当成固定续期周期。

本篇文章就来分享一下Let’s Encrypt Wildcard 免费泛域名SSL证书一键申请与SSL使用教程,更多的关于建站经验与建站资源,你可以试试:

  1. PayPal连连提现五个注意事项-账号绑定,失败锁定,手续费与提现时长
  2. 十个你可能不知道的CloudFlare免费CDN加速技巧-SSL\DDOS\Cache
  3. 自建CDN加速-Nginx反向绑定,缓存加速,自动更新缓存和获取真实IP

PS:2026年11月5日更新,补上 DNS-01、裸域与通配符的覆盖差别,更新签发参数、DNS Token 和证书安装续期步骤。

PS:更新记录。

1、更多的免费SSL证书可以看我收集整理的专题:免费SSL证书收集整理汇总-免费给网站添加Https安全加密访问。2022.6.25 2、详细的letsencrypt免费SSL证书安装教程,参考:简单三步给网站申请安装letsencrypt免费SSL证书-acme.sh自动续期。2022.6.25

一、Let’s Encrypt泛域名SSL证书申请前准备

官网:

  1. https://letsencrypt.org/
  2. https://github.com/Neilpang/acme.sh
  3. https://wzfou.com/vps-bangdan/

1.1  VPS服务器

要安装Let’s Encrypt Wildcard 免费泛域名SSL证书,可以在能运行 acme.sh 的机器上签发,再部署到实际提供 HTTPS 的服务器,关于选购VPS主机可以看我写的各在VPS主机测评:接入CN2线路VPS主机商和机房汇总和VPS主机排行榜单。

不嫌备+案麻烦的话,可以选择阿里云VPS、腾讯云VPS、京东云VPS等国内的VPS主机商,想要速度快的免备+案的VPS,可以试试CN2线路或者香港、韩国机房的VPS,这类有阿里云香港、CN2 VPS、Kdatacenter等等。

1.2  做好DNS解析

先确认哪家服务商托管这个域名的权威 DNS。用它的 API 写入 _acme-challenge TXT 即可,通常无需更换 NS。*.example.com 只覆盖一级子域名,要同时覆盖裸域就再加 example.com。验证方式:https://letsencrypt.org/docs/challenge-types/ 。

二、Let’s Encrypt SSL工具acme.sh

2.1  安装acme.sh

acme.sh 实现了 acme 协议, 可以从 letsencrypt 生成免费的证书。安装很简单, 一个命令:

curl  https://get.acme.sh | sh

普通用户和 root 用户都可以安装使用。 acme.sh 安装到你的 home 目录下:~/.acme.sh/,并创建 一个 bash 的 alias, 方便你的使用: acme.sh=~/.acme.sh/acme.sh

安装后检查当前账号下的定时任务。使用 DNS API 才便于自动续期;如果手动添加 TXT,续期时通常还得重新添加。下面的 DNS 界面和命令记录来自早期 acme.sh。

2.2  获取DNS API

目前acme.sh需要使用到DNS API验证域名。这里以DNSPOD为例,进入到用户中心就可以找到API了。

点击新建一个API。

最后你可以复制API的ID与Key了。

2.3  签发Let’s Encrypt 泛域名证书

这里以DNSPod为演示,如果你是使用的其它的DNS,请参考本文下的附录,不同的DNS的命令是不同的。执行以下命令保存DNSPOD的API Key 和 ID。

export DP_Id="1234"
export DP_Key="sADDsdasdgdsf"

这里的 dns_dp 对应旧版 DNSPod ID/Token 接口;使用腾讯云 API 的朋友按现行插件文档选择对应插件。签发命令显式指定 Let’s Encrypt,通配符用引号包起来:

acme.sh --issue --server letsencrypt --dns dns_dp -d example.com -d '*.example.com'
# 需要明确指定 ECC 曲线时可加 --keylength ec-256
acme.sh --issue --server letsencrypt --dns dns_dp -d example.com -d '*.example.com' --keylength ec-256
#可选长度有:
   ec-256 (prime256v1, “ECDSA P-256”)
   ec-384 (secp384r1, “ECDSA P-384”)

整个签发过程还是很快的,完成后你就可以生成的SSL证书路径了。

签发成功后,用 acme.sh --install-cert 把私钥和完整证书链部署到 Web 服务使用的路径,ECC 证书加 --ecc。同时配置能生效的 --reloadcmd;续期后从外部核对网站实际返回的证书及有效期。别让 Nginx 直接引用 acme.sh 的内部目录。

三、Let’s Encrypt SSL证书安装

实际上目前流行的VPS主机面板都已经支持自定义SSL证书或者是一键申请安装Let’s Encrypt SSL证书了,例如BT.cn宝塔面板、OneinStack、LNMP、WDCP、AppNode面板等。 更多的安装方法请参考:服务器控制面板榜单。

四、附录:各大DNS API获取与签发SSL

说明:

  1. 附录原参考:https://github.com/Neilpang/acme.sh/blob/master/dnsapi/README.md ,现行插件文档:https://github.com/acmesh-official/acme.sh/wiki/dnsapi
  2. DNS解析服务汇总:https://wzfou.com/mianfei-dns/
  3. 以下各 DNS 示例保留历史接口写法。需要泛域名时,把 -d www.example.com 换成 -d '*.example.com',保留裸域参数。

4.1  CloudFlare DNS API

Cloudflare 新配置优先使用仅授权目标域名的 API Token,给它所需的 DNS 编辑及区域读取权限。

export CF_Token="YOUR_ZONE_API_TOKEN"

Ok, let’s issue a cert now:

acme.sh --issue --server letsencrypt --dns dns_cf -d example.com -d '*.example.com'

acme.sh 会保存 DNS 插件的授权配置,限制对应文件的权限,续期时让同一账号读取。

4.2  DNSPod DNS API

First you need to login to your DNSPod account to get your API Key and ID.

export DP_Id="1234"
export DP_Key="sADDsdasdgdsf"

Ok, let’s issue a cert now:

acme.sh --issue --server letsencrypt --dns dns_dp -d example.com -d www.example.com

The DP_Id and DP_Key will be saved in ~/.acme.sh/account.conf and will be reused when needed.

4.3  CloudXNS DNS API

First you need to login to your CloudXNS account to get your API Key and Secret.

export CX_Key="1234"
export CX_Secret="sADDsdasdgdsf"

Ok, let’s issue a cert now:

acme.sh --issue --server letsencrypt --dns dns_cx -d example.com -d www.example.com

The CX_Key and CX_Secret will be saved in ~/.acme.sh/account.conf and will be reused when needed.

4.4  阿里云Aliyun DNS API

First you need to login to your 阿里云 Aliyun account to get your API key. https://ak-console.aliyun.com/#/accesskey

export Ali_Key="sdfsdfsdfljlbjkljlkjsdfoiwje"
export Ali_Secret="jlsdflanljkljlfdsaklkjflsa"

Ok, let’s issue a cert now:

acme.sh --issue --server letsencrypt --dns dns_ali -d example.com -d www.example.com

The Ali_Key and Ali_Secret will be saved in ~/.acme.sh/account.conf and will be reused when needed.

4.5  GoDaddy DNS API

First you need to login to your GoDaddy account to get your API Key and Secret. https://developer.godaddy.com/keys/

Please create a Production key, instead of a Test key.

export GD_Key="sdfsdfsdfljlbjkljlkjsdfoiwje"
export GD_Secret="asdfsdafdsfdsfdsfdsfdsafd"

Ok, let’s issue a cert now:

acme.sh --issue --server letsencrypt --dns dns_gd -d example.com -d www.example.com

The GD_Key and GD_Secret will be saved in ~/.acme.sh/account.conf and will be reused when needed.

4.6  PowerDNS DNS API

First you need to login to your PowerDNS account to enable the API and set your API-Token in the configuration. https://doc.powerdns.com/md/httpapi/README/

export PDNS_Url="http://ns.example.com:8081"
export PDNS_ServerId="localhost"
export PDNS_Token="0123456789ABCDEF"
export PDNS_Ttl=60

Ok, let’s issue a cert now:

acme.sh --issue --server letsencrypt --dns dns_pdns -d example.com -d www.example.com

The PDNS_Url, PDNS_ServerId, PDNS_Token and PDNS_Ttl will be saved in ~/.acme.sh/account.conf and will be reused when needed.

4.7  Amazon Route53 DNS API

方法见:https://github.com/Neilpang/acme.sh/wiki/How-to-use-Amazon-Route53-API

export  AWS_ACCESS_KEY_ID=XXXXXXXXXX
export  AWS_SECRET_ACCESS_KEY=XXXXXXXXXXXXXXX

To issue a cert:

acme.sh --issue --server letsencrypt --dns dns_aws -d example.com -d www.example.com

The AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY will be saved in ~/.acme.sh/account.conf and will be reused when needed.

4.8  Linode DNS API

First you need to login to your Linode account to get your API Key. https://manager.linode.com/profile/api

Then add an API key with label ACME and copy the new key.

export LINODE_API_KEY="..."

Due to the reload time of any changes in the DNS records, we have to use the dnssleep option to wait at least 15 minutes for the changes to take effect.

Ok, let’s issue a cert now:

acme.sh --issue --server letsencrypt --dns dns_linode --dnssleep 900 -d example.com -d www.example.com

The LINODE_API_KEY will be saved in ~/.acme.sh/account.conf and will be reused when needed.

4.9  DigitalOcean DNS API (native)

You need to obtain a read and write capable API key from your DigitalOcean account. See: https://www.digitalocean.com/help/api/

export DO_API_KEY="YOUR_DIGITALOCEAN_API_TOKEN"

Ok, let’s issue a cert now:

acme.sh --issue --server letsencrypt --dns dns_dgon -d example.com -d www.example.com

4.10 Namesilo DNS API

You’ll need to generate an API key at https://www.namesilo.com/account_api.php Optionally you may restrict the access to an IP range there.

export Namesilo_Key="xxxxxxxxxxxxxxxxxxxxxxxx"

And now you can issue certs with:

acme.sh --issue --server letsencrypt --dns dns_namesilo --dnssleep 900 -d example.com -d www.example.com

4.11  使用自定义API

If your API is not supported yet, you can write your own DNS API.

Let’s assume you want to name it ‘myapi’:

  1. Create a bash script named ~/.acme.sh/dns_myapi.sh,
  2. In the script you must have a function named dns_myapi_add() which will be called by acme.sh to add the DNS records.
  3. Then you can use your API to issue cert like this:
acme.sh --issue --server letsencrypt --dns dns_myapi -d example.com -d www.example.com

五、总结

Let’s Encrypt Wildcard 免费泛域名SSL证书申请与安装还是比较简单的,目前我们可以通过脚本来申请Let’s Encrypt泛域名SSL,相信不久之后各大VPS主机控制面板就会有一键申请与安装泛域名SSL证书了。

泛域名续期也要再验证 DNS。先核对定时任务、DNS 权限和部署路径,再确认站点实际提供的是新证书。

文章出自:挖站否 https://wzfou.com/lets-encrypt-wildcard-ssl/,版权所有。本站文章除注明出处外,皆为作者原创文章,可自由引用,但请注明来源。

文章更新于: 2026年11月5日 上午12:33

Qi

关于站长(Qi),2008年开始混迹于免费资源圈中,有幸结识了不少的草根站长。之后自己摸爬滚打潜心学习Web服务器、VPS、域名等,兴趣广泛,杂而不精,但愿将自己经验与心得分享出来与大家共勉。

查看评论