官方说明
https://github.com/acmesh-official/acme.sh/wiki/%E8%AF%B4%E6%98%8E
以下使用dns 方式进行验证,使用了cloudflare 的api。
安装acme.sh
#下面的邮箱换成你的
curl https://get.acme.sh | sh -s email=my@example.com
#安装完成后断开ssh,并重新连接,以使acme生效,然后执行命令,显示版本则说明安装成功
acme.sh --version
acme.sh --set-default-ca --server letsencrypt
证书申请
需提前登陆cloudflare 创建并找到以下 环境变量信息。
参考 https://u.sb/acme-sh-ssl/
# 环境变量声明
export CF_Token="xxxxxxxxxxx"
export CF_Account_ID="xxxxxxxxxxxx"
export CF_Zone_ID="xxxxxxxxxxx"
# 申请证书,以 dns cloudflare 验证
# xx.xxxx.com 为要申请的域名
acme.sh --issue --dns dns_cf -d xx.xxxx.com
# 创建证书使用目录
mkdir /usr/local/cert
# 安装证书
acme.sh --install-cert -d xx.xxxx.com \
--key-file /usr/local/cert/xx.xxxx.com.key \
--fullchain-file /usr/local/cert/xx.xxxx.com.crt \
--ca-file /usr/local/cert/xx.xxxx.com.ca.crt \
--reloadcmd "systemctl restart xxxx"
# --reloadcmd 为安装证书后自动重启使用证书的程序,如nginx,则使用命令 systemctl restart nginx