Bboysoul's Blog

首页 公告 RSS

使用阿里云域名api申请Let’s Encrypt泛域名免费ssl证书

March 15, 2018 本文有 581 个字 需要花费 2 分钟阅读

概述

首先说下什么是泛域名,比如我要做两个网站第一个网站是hello.google.com,第二个是well.google.com,那么通常我要申请两个ssl证书来给每一个网站,但是泛域名就是我只要申请一个*.google.com证书就能同时给两个网站使用了

环境准备

首先我们要有一台linux,debian系列的和红帽系列的都可以,之后我们安装一些环境依赖

  • debian系列

apt-get update && apt-get install curl -y && apt-get install cron -y && apt-get install socat -y

  • 红帽系列

yum update && yum install curl -y && yum install cron -y && yum install socat -y

下载ACME.SH并且执行

这个脚本就是用来申请免费证书的脚本
curl https://get.acme.sh | sh

导入阿里云的Access Key ID和Access Key Secret到环境变量中

阿里云的Access Key ID和Access Key Secret可以在下面这个页面中登录获取
https://account.aliyun.com/login/login.htm?oauth_callback=https%3A%2F%2Fak-console.aliyun.com%2F%3Fspm%3D5176.2020520001.0.0.0EJtVx#/accesskey

export Ali_Key=""
export Ali_Secret=""

申请证书

接下来就是申请证书了,大家把下面的bboysoul.cn换成自己的域名就好

如果你使用zsh可能会执行不成功,使用bash执行

~/.acme.sh/acme.sh --issue --dns dns_ali -d bboysoul.cn -d *.bboysoul.cn

出现下面这几行表示成功

[Thu Mar 15 11:09:05 CST 2018] Your cert is in  /root/.acme.sh/bboysoul.cn/bboysoul.cn.cer 
[Thu Mar 15 11:09:05 CST 2018] Your cert key is in  /root/.acme.sh/bboysoul.cn/bboysoul.cn.key 
[Thu Mar 15 11:09:05 CST 2018] The intermediate CA cert is in  /root/.acme.sh/bboysoul.cn/ca.cer 
[Thu Mar 15 11:09:05 CST 2018] And the full chain certs is there:  /root/.acme.sh/bboysoul.cn/fullchain.cer 

之后把这些证书下载下来就好了,所有文件在.acme.sh/你的域名 目录下面

最后说几句

宝塔面板是支持一键申请Let’s Encrypt的证书的,但不是泛域名证书,不过方便了很多

欢迎关注我的博客www.bboy.app
Have Fun


Tags:

本站总访问量 本站总访客数