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

要说免费SSL证书,绝对要推荐Let’s Encrypt,申请免费,安装简单,可以无限期的续期。目前wzfou.com主站用的就是Let’s Encrypt的免费SSL证书,有人担心自己没有VPS主机无法使用Let’s Encrypt证书,其实现在你可以直接在线申请Let’s Encrypt了。

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

acme.sh 实现了 acme 协议, 可以从 letsencrypt 生成免费的证书。主要步骤:安装 acme.sh、生成证书 、copy 证书到 nginx/apache 或者其他服务 、更新证书 、更新 acme.sh。Let’s Encrypt Wildcard 免费泛域名SSL证书有效期依然为三个月,acme.sh会自动续期。

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

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

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

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证书,你至少需要一台VPS主机,关于选购VPS主机可以看我写的各在VPS主机测评:接入CN2线路VPS主机商和机房汇总VPS主机排行榜单

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

1.2  做好DNS解析

Let’s Encrypt支持DNSPod、CloudXNS、Amazon Route53、CloudFlare等DNS解析,你需要先把域名的NS修改好。

Let’s Encrypt Wildcard 做好解析

二、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

Let’s Encrypt Wildcard 安装脚本

同时acme.sh 自动为你创建 cronjob, 每天 0:00 点自动检测所有的证书, 如果快过期了, 需要更新, 则会自动更新证书。安装过程不会污染已有的系统任何功能和文件, 所有的修改都限制在安装目录中: ~/.acme.sh/

2.2  获取DNS API

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

Let’s Encrypt Wildcard 获得API

点击新建一个API。

Let’s Encrypt Wildcard 新建一个

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

Let’s Encrypt Wildcard 复制ID

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

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

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

这个 DP_Id and DP_Key 保存在 ~/.acme.sh/account.conf 。执行以下命令就可以签发Let’s Encrypt 泛域名证书了:

acme.sh --issue --dns dns_dp -d wzfou.com -d *.wzfou.com
#默认签发的是RSA,如果你想签发ECC证书,请使用以下命令
acme.sh --issue --dns dns_dp -d wzfou.com -d *.wzfou.com --keylength ec-256
#可选长度有:
   ec-256 (prime256v1, “ECDSA P-256”)
   ec-384 (secp384r1, “ECDSA P-384”)

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

Let’s Encrypt Wildcard 成功安装

现在打开证书路径,Fullchain.cer就是完成的域名证书了,wzfou.com.key就是Key了,你只要下载这两个文件就可以启用Let’s Encrypt SSL证书了。

Let’s Encrypt Wildcard 打开路径

三、Let’s Encrypt SSL证书安装

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

Let’s Encrypt Wildcard 证书安装

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

说明:

  1. 附录参考自:https://github.com/Neilpang/acme.sh/blob/master/dnsapi/README.md
  2. DNS解析服务汇总:https://wzfou.com/mianfei-dns/
  3. 签发泛域名SSL时请把命令部分:-d www.example.com 改成 :-d *.example.com

4.1  CloudFlare DNS API

First you need to login to your CloudFlare account to get your API key.

export CF_Key="sdfsdfsdfljlbjkljlkjsdfoiwje"
export CF_Email="[email protected]"

Ok, let’s issue a cert now:

acme.sh --issue --dns dns_cf -d example.com -d www.example.com

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

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 --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 --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 --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 --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 --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 --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 --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="75310dc4ca779ac39a19f6355db573b49ce92ae126553ebd61ac3a3ae34834cc"

Ok, let’s issue a cert now:

acme.sh --issue --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 --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 --dns dns_myapi -d example.com -d www.example.com

五、总结

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

Let’s Encrypt Wildcard成功使用

Let’s Encrypt Wildcard 免费泛域名SSL证书需要用到DNS验证,附录里已经列出了各大DNS域名解析获取API以及签发SSL证书的命令,大家可以参考一下,如果是签发泛域名SSL,请把www换成*号即可。

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


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

    可是我是win的主机啊 这个。。。这个。。咋整

    2018年4月6日 14:17 回复
    • Avatar for Qi Qi

      Windows貌似不行,只能通过在线申请的方式了。https://wzfou.com/ssl-for-free/

      2018年4月7日 11:40 回复
  2. Avatar for Astrokite Astrokite

    卡在 Found domain api file: /root/.acme.sh/dnsapi/dns_ali.sh

    2018年3月26日 17:25 回复
    • Avatar for Qi Qi

      用的阿里的DNS?看看有没有/root/.acme.sh/dnsapi/dns_ali.sh这个文件?

      2018年3月27日 13:40 回复
    • 后来成功没?
      我也用的aliyun的dns,一次成功。

      2018年4月8日 16:29 回复
      • Avatar for Astrokite Astrokite

        成功了,我都忘了怎么解决的了,哈哈

        2018年4月8日 17:48来自iPhone 回复
  3. 大佬,dns.he.net这个API能怎么搞。这个有api吗。

    2018年3月24日 13:55 回复
  4. let’s的证书拿来VPS上面建站加密确实非常方便。
    我现在用七牛的CDN,要加HTTPS,本来用的也是let’s,但是三个月一换证书太麻烦了,后来就改成阿里云的免费证书了,一年有效期
    阿里云的证书之前用的是赛门铁克,赛被封杀之后阿里换了个颁发者,叫做anywhere encryption什么的,打的旗号还是赛门铁克

    2018年3月23日 23:43 回复
  5. Q, 发现你文章都是隔三天发布。请问博主是如何那么高产的?你写的文章深入,内容质量高。博主有什么文章创作经验分享么?博主写一篇文章要多久?

    2018年3月20日 22:20来自移动端 回复
    • Avatar for Qi Qi

      至少要一天,有些还得两三天,比较消耗时间。写文章之前主要还是靠前期资料收集与积累。

      2018年3月21日 10:47 回复
      • Avatar for Astrokite Astrokite

        收集整理的资料放在哪?

        2018年3月26日 17:26 回复
        • Avatar for Qi Qi

          放在邮箱里或者是印象笔记里,这样积累起来就慢慢多了。

          2018年3月27日 13:37 回复
  6. 虚拟主机用的也是这个,但是是通过https://www.sslforfree.com/ 这个方式的

    2018年3月19日 16:21 回复
    • Avatar for Qi Qi

      虚拟主机得自己每三个更换一次证书,这个有些麻烦了。

      2018年3月21日 12:41 回复
  7. 博主有研究自动续期是怎么实现的吗?
    自动续期是只生成延期证书吗?还需要手动配置nginx吗?

    2018年3月19日 09:11 回复
    • Avatar for Qi Qi

      用定时任务自动更新证书,自动续期实际就是重新签发一个三个月有效期的SSL证书,自动续期的话是不用再配置Nginx,证书会自动替换掉,所以只要重启一个Nginx就好了。

      2018年3月21日 12:45 回复
    • 做# adsense比较稳定,不用动脑筋。我其他做美亚联盟

      2018年3月21日 13:06 回复
  8. 不能赚钱的博客,很难检查。Q 有什么经验可以分享给新手。谢谢!

    2018年3月18日 16:20 回复
    • Avatar for Qi Qi

      我也一直在纠结这个事情,写个博客不赚钱的话基本上就是废掉的。目前可行的方式有做Affiliate,有尝试过吗?

      2018年3月18日 16:35 回复
  9. Q你页面只有一个GG广告,能负担的起WZFou的主机和域名吗,及人力成本吗?

    2018年3月18日 16:17 回复
    • Avatar for Qi Qi

      根本不行,一天才一两块钱,我也是放着玩,Adsense还影响网页加载速度,好多地方都打不开。

      2018年3月18日 16:36 回复
  10. 据说以后的证书时长都会慢慢改为3个月,似乎是在沃通上看到过。

    2018年3月18日 14:38来自移动端 回复
    • Avatar for Qi Qi

      付费的SSL也要三个月?

      2018年3月18日 16:42 回复
      • Avatar for 林间小鹿 林间小鹿

        能啊,上一个alphassl某宝卖的风生水起……

        2018年3月18日 20:06来自移动端 回复
        • Avatar for Qi Qi

          我找到了发家致富的方法了。

          2018年3月21日 13:23 回复
  11. let’s encrypt的证书一直在用,唯一蛋疼的就是3个月续一次

    2018年3月18日 13:38 回复
  12. Avatar for 林间小鹿 林间小鹿

    这个就很方便很实用了!目测某宝要出来一大堆代申请证书的了…… 🙂 🙂

    2018年3月18日 13:20来自移动端 回复
    • Avatar for Qi Qi

      这个还能赚钱?

      2018年3月18日 16:42 回复
  13. 如果用了CDN 证书还会自动更新么

    2018年3月18日 09:45 回复
    • Avatar for Qi Qi

      CDN是自定义证书的话还得自己到CDN那里更新一下证书。本地肯定会自动更新SSL证书的。

      2018年3月18日 10:03 回复
      • 不是指向的IP也可以自动更新吗?我现在是自己弄的这证书,用的军哥一键安装包,如果在用这个是之前生成证书,还是把之前的删掉重新添加域名

        2018年3月18日 10:06 回复
  14. Avatar for SaintW SaintW

    🌚 还少了 RSA 和 ECC 的命令项啊

    2018年3月18日 05:24来自iPhone 回复
    • Avatar for Qi Qi

      谢谢,已经更新,只需要在命令后面加上–keylength ec-256

      2018年3月18日 10:25 回复
  15. 三个月换一次 很麻烦呀

    2018年3月18日 02:14 回复
    • Avatar for Qi Qi

      有点麻烦,适合有VPS主机的用。

      2018年3月18日 10:26 回复
  16. Free Wildcard,oAO改天一定試試!

    2018年3月18日 00:38 回复
  17. 这个还支持同证书多个泛域申请,全部域名一张证书解决。目前比较大的问题是各个面板、一键包好像都还不支持直接申请泛域,必须单独用acme.sh

    2018年3月17日 22:40来自移动端 回复
    • Avatar for Qi Qi

      是的,相信过一段时间就有了,毕竟那些面板基本上都是集成的acme.sh这个脚本。

      2018年3月18日 10:28 回复
  18. 这下Let’s encrypt实用性更高了

    2018年3月17日 22:14 回复
  19. 终于来了

    2018年3月17日 22:11 回复
  20. Avatar for saber saber

    有空试下 🙂

    2018年3月17日 22:05 回复
    • Avatar for Qi Qi

      很好用,有空试试。

      2018年3月18日 10:28 回复
  21. Avatar for wo wo

    这下卖SSL的要着急了。。。

    2018年3月17日 20:47 回复

Login

Welcome! Login in to your account

Remember me Lost your password?

Don't have account. Register

Lost Password

Register