Lazy loaded image
运维管理
step ACME 管理
Words 763Read Time 2 min
2025-10-1
2025-11-10
date
related_level
slug
type
relate_date
summary
status
tags
category
last_updated
Nov 10, 2025 10:02 PM
是否已更新
orginal_page
是否推荐
参考资料
 

step 开启 ACME 支持及 ACME 测试

step 添加 ACME 类型的供应商 provisioner
  • step ca provisioner add acme --type ACME
  • 需要重启 CA
step 会启动 web server 来响应 step CA 的 ACME 挑战
  • https://{ca-host}/acme/{provisioner-name}/directory
    • {provisioner-name} 默认为 acme
      • 可以通过 step ca provisioner list | jq '.[] | select(.type == "ACME")' 确认
    • 需要客户端信任 step-ca 的 CA 根证书
  • 使用 step 作为 ACME 客户端通过 HTTP-01 挑战申请证书
    • step ca certificate --provisioner acme example.com example.crt example.key
  • 使用 step 作为 ACME 客户端通过 DNS-01 挑战申请证书
    • step ca certificate --provisioner acme example.com example.crt example.key
 

配置常用 ACME 客户端使用私有CA

  • step acme 需要客户端信任 step 签发的 CA 根证书
Certbot
签发证书
  • sudo REQUESTS_CA_BUNDLE=$(step path)/certs/root_ca.crt \ certbot certonly -n --standalone -d foo.internal \ --server https://ca.internal/acme/acme/directory
    • REQUESTS_CA_BUNDLE 指定 CA 证书
    • --server 指定 ACME CA 服务器
  • 执行 HTTP 挑战需要 sudo 指令让 certbot 启动 web 服务器
续订证书
  • sudo REQUESTS_CA_BUNDLE=$(step path)/certs/root_ca.crt certbot renew
通过 cron 自动续订
  • */15 * * * * root REQUESTS_CA_BUNDLE=$(step path)/certs/root_ca.crt certbot -q renew
    • 每 15 分钟一次
  • 部分 linux 发行版本下 certbot 自动生成的 cron 自动续订因为没带 REQUESTS_CA_BUNDLE 而不会生效,需要自行修改
修改续订时间
  • /etc/letsencrypt/renewal/foo.internal.conf
    • renew_before_expiry = 8 hours
ACME.SH
签发证书
  • sudo acme.sh --issue --standalone -d foo.internal \ --server https://ca.internal/acme/acme/directory \ --ca-bundle $(step path)/certs/root_ca.crt \ --fullchain-file foo.crt \ --key-file foo.key
    • --ca-bundle 指定 CA 证书
    • --server 指定 ACME CA 服务器
通过 cron 自动续订
  • 0 */8 * * * root "/home/<user>/.acme.sh"/acme.sh --cron --home "/home/<user>/.acme.sh" --force > /dev/null
  • ACME.SH 会记住 CA 证书,无需指定
nginx
  • nginx 并不能原生支持 ACME,但可以通过截断 TLS 并代理到监听本地环回地址的后端服务器上来实现 ACME 客户端
HTTP 挑战
nginx 监听 443 端口并配置对应证书和密钥,代理到本地环回地址(端口 8000)
通过 python 在端口 8000 上启动简单的后端服务器
  • echo "Hello TLS!" > index.html
  • python -m SimpleHTTPServer 8000 & curl https://foo.internal --cacert $(step path)/certs/root_ca.crt
nginx 续订证书
  • nginx 仅在启动时读取一次证书,因此需要在续订后重新读取配置
  • step ca renew --daemon --exec "nginx -s reload" \ /path/to/foo.crt \ /path/to/foo.key
    • step ca
  • certbot renew --pre-hook "service nginx stop" --post-hook "service nginx start"
    • certbot
  • for i in /etc/letsencrypt/live/*; do acme.sh --install-cert -d $(basename $i) --home "/root/.acme.sh/" --cert-home "/etc/letsencrypt/live" --reloadcmd "service nginx reload"; done
    • acme.sh
node:node-acme-client
使用 node-acme-client 提供 ACME HTTPS 挑战服务器
  • npm install node-acme-client
验证是否配置成功
  • curl https://bar.internal:11443 --cacert $(step path)/certs/root_ca.crt
  • curl https://bar.internal:11443 --cacert $(step path)/certs/root_ca.crt --cert mike.crt --key mike.key
    • 可选,使用证书和密钥验证客户端
python
  • certbot 就是 python 编写的
使用 https.py 提供 ACME HTTPS 挑战服务器
  • 安装依赖
    • pip install acme
    • pip install pem
验证是否配置成功
  • curl https://bar.internal:11443 --cacert $(step path)/certs/root_ca.crt
  • curl https://bar.internal:11443 --cacert $(step path)/certs/root_ca.crt --cert mike.crt --key mike.key
    • 可选,使用证书和密钥验证客户端
 
上一篇
step-cli 配置及使用
下一篇
使用 OpenSSL 自建 Root CA

Comments
Loading...