跳转至内容

acme.sh

来自 ArchWiki

acme.sh 是一个完全用 Shell 脚本编写的 ACME 客户端。它实现了完整的 ACME 协议,并且支持 IPv6 和通配符证书等。

安装

安装 acme.sh 包,如果您想使用独立模式,还需要安装 socat

用法

该软件包不提供 man 手册页,但其 wiki 提供了使用说明。执行 acme.sh --help 会输出长串的命令和参数列表。

涉及三个基本步骤

  1. 请求颁发证书。
  2. 安装已颁发的证书,使其生效。
  3. 长期维护证书。

如下面的示例所示。

颁发新证书

您可以使用 -d 选项指定任何域名。

提示 您可能希望将 Let's Encrypt 指定为默认 CA,因为从 2021-08-01 起 acme.sh 的默认 CA 为 ZeroSSL。

acme.sh 脚本支持不同的模式。以下是模式和要指定的选项的示例:

  • Webroot 模式
    $ acme.sh --issue -d example.com -d www.example.com -d cp.example.com -d '*.example.com' -w /home/wwwroot/example.com
  • 独立模式,通过添加 --standalone 来实现,如果没有运行 Web 服务器(需要安装 socat)。
    $ acme.sh --issue --standalone -d example.com -d www.example.com -d cp.example.com
  • Nginx 模式
    $ acme.sh --issue --nginx -d example.com -d www.example.com -d cp.example.com
  • DNS 模式:
    $ acme.sh --issue -d example.com -d '*.example.com' --dns dns_he

该项目的 wiki 列出了 更多示例

将证书安装到 Apache/Nginx 等

Nginx

$ 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    "systemctl force-reload nginx"

Apache

$ acme.sh --install-cert -d example.com \
   --cert-file        /path/to/certfile/in/apache/cert.pem  \
   --key-file         /path/to/keyfile/in/apache/key.pem  \
   --fullchain-file /path/to/fullchain/certfile/apache/fullchain.pem \
   --reloadcmd    "systemctl force-reload httpd"

维护证书

证书将每 60 天续订一次。要定期运行 acme.sh,可以设置一个 systemd 定时器

参见

  • 项目主页wiki 提供了其文档。
  • acme-tiny 提供了一些相关的实用工具,以及其他通用的 ACME 文档。
  • lacme 是一个小型 ACME 客户端,它在设计时考虑了进程隔离和最小权限。

© . This site is unofficial and not affiliated with Arch Linux.

Content is available under GNU Free Documentation License 1.3 or later unless otherwise noted.