GTS 是 Google 旗下的证书品牌, 支持 ACME, 支持 ECC, 本站的证书就是 GTS 签发的, 本文将介绍如何在服务器上使用 acme.sh 签发 GTS 证书.
需要注意的是, 签发 GTS 证书需要在申请 Key 的时候可以连接到 Google 服务, 但申请到 Key 后, 可以在大陆服务器签发证书, 且 Google 的 OCSP 有内地访问节点, 没有被屏蔽.
申请 Google Cloud Platform 密钥
打开 shell.cloud.google.com, 输入以下内容:
gcloud beta publicca external-account-keys create
按提示输入 Project ID, 然后
Shift + Command/Ctrl + R
刷新后重新输入上方代码如果你没用使用过 GCP, 需要先新建一个 Project, 进入下方链接创建:
https://console.cloud.google.com/home/dashboard
将 b64MacKey
和 keyId
保存在安全的地方
安装配置 acme.sh
连接到 SSH, 输入
curl https://get.acme.sh | sh -s
然后切换到安装目录
cd /root/.acme.sh/
设置 GTS 为默认证书
./acme.sh --set-default-ca --server google
配置 Key
./acme.sh --server https://dv.acme-v02.api.pki.goog/directory \
--register-account --accountemail <Your_Gmail> --eab-kid <keyid> --eab-hmac-key <b64mac_key>
看到 Registered
提示即为注册成功
签发证书
使用 TXT 验证签发证书
acme.sh --issue --dns -d yourdomain.com \
--yes-I-know-dns-manual-mode-enough-go-ahead-please
然后根据提示去 DNS 解析商那里设置 TXT 记录
然后使用 dig 检测解析是否生效
dig txt <_acme-challenge.domain> @1.1.1.1
检测解析生效后, 输入
acme.sh --renew -d yourdomain.com \
--yes-I-know-dns-manual-mode-enough-go-ahead-please
然后就可以在 ~/.acme.sh/yourdomain.com/
下面找到生成的证书了
(找不到的话就 ls -la
看一下目录)
使用 API 签发证书
此处以 Cloudflare API
为例, 更多的 DNS 托管商 API 获取方式见 acme.sh wiki
通过此链接获取 Global API Key
然后在命令行中输入
export CF_Key='<GlobalAPIKey>'
export CF_Email="<Email>"
使用 Cloudflare API
签发的命令如下
# 单域名
./acme.sh --issue --dns dns_cf -d yourdomain.com
# (多)子域名
./acme.sh --issue --dns dns_cf -d 1.yourdomain.com -d 2.yourdomain.com
# 泛域名
./acme.sh --issue --dns dns_cf -d *.yourdomain.com
#ECC 证书
./acme.sh --issue --dns dns_cf -d yourdomain.com --ecc
如果不再使用 Cloudflare API
, 可以删除此文件 ~/.acme.sh/account.conf