On This Page
ACME(Automatic Certificate Management Environment)是一种由IETF(Internet Engineering Task Force)制定的协议,用于自动化管理SSL/TLS证书的获取、更新和撤销过程。ACME协议的主要目的是简化证书管理流程,提高证书的安全性和可靠性。
ACME协议定义了客户端(如Certbot、acme.sh等)与证书颁发机构(CA)之间的通信流程和规范,使得证书的申请、验证和更新可以自动化进行。通过ACME协议,客户端可以向CA发起证书签发请求,并通过一系列验证步骤来证明域名的所有权,最终获取有效的SSL/TLS证书。
ACME协议的一个重要特点是支持多种验证方式,包括HTTP验证、DNS验证等,以满足不同场景下的证书申请需求。同时,ACME协议还规定了证书的有效期和更新机制,使得证书的管理更加便捷和安全。
总的来说,ACME协议是一种用于自动化管理SSL/TLS证书的标准化协议,为网站管理员和开发人员提供了更简单、更安全的证书管理解决方案。
curl https://get.acme.sh | sh -s [email protected]
email为个人email地址,用来向ca注册.
该命令将acme.sh安装只home下~/.acme.sh/
,并设置了一个shell别名alias acme.sh=~/.acme.sh/acme.sh
acme.sh --uninstall
从git拉取代码并安装
git clone --depth 1 https://github.com/acmesh-official/acme.sh.git
cd acme.sh
./acme.sh --install \
--home ~/myacme \
--config-home ~/myacme/data \
--cert-home ~/mycerts \
--accountemail "[email protected]" \
--accountkey ~/myaccount.key \
--accountconf ~/myaccount.conf \
--useragent "this is my client."
--home
:是要安装在其中的自定义目录。默认情况下,它安装在acme.sh~/.acme.sh--config-home
:是一个可写的文件夹,acme.sh 将在那里写入所有文件(包括证书/密钥、配置)。默认情况下,它位于--home
--cert-home
:是一个自定义的目录,用于保存您颁发的证书。默认情况下,它保存在 中。--config-home
--accountemail
:是用于注册 Let’s Encrypt 帐户的电子邮件,您将在此处收到续订通知电子邮件。--accountkey
:是保存帐户私钥的文件。默认情况下,它保存在 中。--config-home
--useragent
:是用于发送到 Let’s Encrypt 的 user-agent 标头值。--nocron
:在没有 cronjob 的情况下安装 acme.shacme.sh --set-default-ca --server letsencrypt
将CA服务器修改letsencypt,这个比较好用
acme.sh --issue --dns -d *.54year.com \
--yes-I-know-dns-manual-mode-enough-go-ahead-please
acme.sh --renew -d *.54year.com \
--yes-I-know-dns-manual-mode-enough-go-ahead-please
export Ali_Key="<key>"
export Ali_Secret="<secret>"
./acme.sh --issue --dns dns_ali -d example.com -d *.example.com
PS:-d example.com -d *.example.com:指添加多个域名到同一个证书中
证书申请后key sec会被保存下来,保存路径:~/.acme.sh/account.conf
chmod -R 777 /path/to/keyfile/in/nginx && service nginx force-reload
acme.sh --install-cert -d example.com \
--key-file /path/to/keyfile/in/nginx/key.pem \
--fullchain-file /path/to/fullchain/nginx/cert.pem \
--reloadcmd "service nginx force-reload"
acme.sh --info -d example.com
# 会输出如下内容:
DOMAIN_CONF=/root/.acme.sh/example.com/example.com.conf //配置文件地址
Le_Domain=example.com //主域名
Le_Alt=no //备用域名,及一个证书中多个域名
Le_Webroot=dns_ali //申请方式
Le_PreHook=
Le_PostHook=
Le_RenewHook=
Le_API=https://acme-v02.api.letsencrypt.org/directory //ca请求地址
Le_Keylength=
Le_OrderFinalize=https://acme-v02.api.letsencrypt.org/acme/finalize/23xxxx150/781xxxx4310
Le_LinkOrder=https://acme-v02.api.letsencrypt.org/acme/order/233xxx150/781xxxx4310
Le_LinkCert=https://acme-v02.api.letsencrypt.org/acme/cert/04cbd28xxxxxx349ecaea8d07
Le_CertCreateTime=1649358725 //证书创建时间
Le_CertCreateTimeStr=Thu Apr 7 19:12:05 UTC 2022 //创建时间str
Le_NextRenewTimeStr=Mon Jun 6 19:12:05 UTC 2022 //下次更新时间
Le_NextRenewTime=1654456325
Le_RealCertPath=
Le_RealCACertPath=
Le_RealKeyPath=/etc/acme/example.com/privkey.pem //安装的key路径
Le_ReloadCmd=service nginx force-reload //安装后执行的reload命令
Le_RealFullChainPath=/etc/acme/example.com/chain.pem //安装的证书路径
crontab -l
:查看定时更新任务acme.sh --upgrade
:更新acme.shacme.sh --upgrade --auto-upgrade
:开启自动更新acme.shacme.sh --upgrade --auto-upgrade 0
:关闭自动更acme.sh