使用 acme.sh 来管理 letsencrypt 证书

安装 acme.sh

1
2
curl https://get.acme.sh | sh -s email=[email protected]
source ~/.bashrc

发布一个证书

使用 dns_cf 插件来申请泛域名证书。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Cloudflare
export CF_Token="sdfsdfsdfljlbjkljlkjsdfoiwje"
export CF_Zone_ID="xxxxxxxxxx"

acme.sh --issue --dns dns_cf -d example.com -d '*.example.com' --keylength ec-256 --server letsencrypt

# 输出证书指纹
openssl x509 -noout -fingerprint -sha256 -in ~/.acme.sh/example.com_ecc/fullchain.cer

# 导出 pkcs12 文件
acme.sh --to-pkcs12 -d example.com --password 123456 --ecc

目前 acme.sh 支持大多数dns提供商:

https://github.com/acmesh-official/acme.sh/wiki/dnsapi

安装这个证书

1
2
3
4
5
6
7
mkdir -p /usr/local/share/ssl
acme.sh --install-cert -d example.com \
  --cert-file /usr/local/share/ssl/example.com.pem \
  --key-file /usr/local/share/ssl/example.com.key \
  --fullchain-file /usr/local/share/ssl/fullchain.pem \
  --ca-file /usr/local/share/ssl/ca.pem \
  --reloadcmd "systemctl force-reload nginx"  # 证书更新后的重载命令

删除一个证书

1
acme.sh --remove -d example.com
使用 Hugo 构建
主题 StackJimmy 设计