杨梅冲
每天在想什么呢?

1.1 简介

acme.sh 是一种轻量的证书管理工具,主要特点是:

  支持与 Let's Encrypt 和其他证书颁发机构(CA)对接。

  通过命令行界面(CLI)自动化整个证书申请、更新和安装流程。

  它还支持 ECC(Elliptic Curve Cryptography)证书,这些证书较小且具有更高的安全性。

1.2 安装方法

1.下载并安装acme.sh
wget -O -  https://get.acme.sh | sh -s email=my@example.com

2.设置环境变量
vim /root/.bash_profile
export LE_WORKING_DIR="/root/.acme.sh"
alias acme.sh="/root/.acme.sh/acme.sh"

3.开启 acme.sh 的自动升级
acme.sh --upgrade --auto-upgrade

4.指定申请的证书为‌Let's Encrypt
#证书品牌由acme.sh 脚本决定,其申请的证书品牌通常为 Let's Encrypt、ZeroSSL 等。
acme.sh --set-default-ca --server letsencrypt

5. 申请证书
第一种方式:http申请
acme.sh --issue -d www.xxx.com -d xxx.com -w /data/service/nginx/xxx/ --keylength ec-256 --force
-d 指定域名,可以指定多个域名
-w 用于指定‌域名所有权验证时的网站根目录路径

第二种申请方式:目前服务器前面都有负载均衡,所以验证域名是否是所有者直接在域名解析里自动添加一条解析,这种需要平台SecretId 和 SecretKey,以阿里云为例:
5.2.1 去阿里云账号下生产SecretId 和 SecretKey,并加上云解析的权限策略
5.2.2 在服务器环境里添加
     vim /etc/profile
     export Ali_Key="<Your SecretId>"
     export Ali_Secret="<Your SecretKey>"

     source /etc/profile

5.2.3 使用 DNS 验证方式申请证书
acme.sh --issue -d www.xxx.com -d xxx.com --dns dns_ali
dns_ali  代表阿里云平台
dns_cf  代表cloudflare平台
dns_tencent  代表腾讯平台

6.安装证书
acme.sh --install-cert -d www.xxx.com -d xxx.com --key-file /data/service/ssl_keys/xxx/www.xxx.com.key --fullchain-file /data/service/ssl_keys/xxx/fullchain.cer --reloadcmd "/usr/local/openresty/nginx/sbin/nginx -s reload"

7.手动续期
acme.sh --renew -d www.xxx.com -d xxx.com --force

1.3 其它命令

// 执行出错怎么办
// 执行错误,可以查看日志,或者执行命令添加--debug 2参数,开启debug模式
[root@ .acme.sh]# ./acme.sh --issue  .....  --debug 2
// 查看当前证书
[root@ .acme.sh]# ./acme.sh --list
// 手动更新全部
[root@ .acme.sh]# ./acme.sh --renew-all
// 手动更新个别
[root@ .acme.sh]# ./acme.sh --renew -d 域名
// 吊销证书
[root@ .acme.sh]# ./acme.sh --revoke   -d 域名
// 移除证书
[root@ .acme.sh]# ./acme.sh --remove -d 域名

 

posted on 2026-03-24 22:12  杨梅冲  阅读(71)  评论(0)    收藏  举报