
ACME Shell 自动申请 SSL 证书
ACME Shell
自动颁发和更新免费证书的 shell 脚本。每 60 天自动更新证书
安装 socat
1 | yum install socat -y |
- 安装 acme.sh
1 | curl https://get.acme.sh | sh -s [email protected] |
普通申请 SSL 证书
推荐使用自动 DNS API 集成申请证书 (支持通配符号)
- 申请证书
- -d 是您要为其颁发证书的域名
1 | acme.sh --issue -d bitwarden.kl.do -w /www/wwwroot/bitwarden.kl.do |
自动 DNS API 集成申请证书 (推荐)
如果您的 DNS 提供商支持 API 访问,我们可以使用该 API 自动颁发证书。
您无需手动执行任何操作!
目前 acme.sh 支持大多数 dns 提供者:
https://github.com/acmesh-official/acme.sh/wiki/dnsapi
DNSPod.cn
获取 DNSPod API 密钥和 ID。
https://console.dnspod.cn/account/token/token
设置环境变量
1 | export DP_Id="1234" |
DP_Id
and 将 DP_Key
被保存 ~/.acme.sh/account.conf
并在需要时被重用。
- 申请证书
- 单域证书
1 | acme.sh --issue --dns dns_dp -d kl.do |
- 通配符证书
1 | acme.sh --issue --dns dns_dp -d kl.do -d '*.kl.do' |
安装证书
请找到自己的 Nginx 证书路径
acme.sh 每 60 天会自动更新一次
更新证书后,Apache/Nginx 服务将通过以下命令自动重新加载:service nginx reload
所以请务必配置到安装的证书路径
1 | acme.sh --install-cert -d example.com \ |
例:宝塔面板
- /www/server/panel/vhost/cert/kl.do Nginx 站点 SSL 证书路径
- /www/server/panel/vhost/ssl 宝塔 SSL 证书夹 - 用于可视化界面部署
1 | mkdir -p /www/server/panel/vhost/ssl/kl.do |
手动更新证书
不,您不需要手动更新证书。所有证书将每 60 天自动更新一次。
但是,您也可以强制更新证书:
1 | acme.sh --renew -d example.com --force |
常用命令
查看证书列表
1 | acme.sh list |
查看定时更新任务
1 | acme.sh cron |
撤销证书
1 | acme.sh --revoke -d example.com |
安装中间证书
检测地址: https://www.myssl.cn/tools/check-server-cert.html
获取中间证书: https://www.myssl.cn/tools/downloadchain.html
- 获取安装证书
将/www/server/panel/vhost/cert/kl.do/cert.pem
内容复制到上面地址中获得中间证书 - 复制中间证书到
/www/server/panel/vhost/cert/kl.do/fullchain.pem
文件下 - 重启 nginx
- 检测证书
- Thanks for your appreciation. / 感谢您的赞赏
赞赏名单
Because of your support, I realize the value of writing articles. / 由于您的支持,我才能够实现写作的价值。
本文是原创文章,采用CC BY-NC-SA 4.0协议,完整转载请注明来自Go知行
评论