前言

最近谷歌开放了自家的 GTS CA(Google Trust Services),谷歌作为全球大厂那不得好好嫖一下!目前该服务进入了 Public Review 阶段,不再需要申请内测资格,而且支持acme.sh快速申请,那不就是嫖他的好日子来了吗!

证书简介

GTS SSL 证书的特点是

  • 支持 IP 地址块持有者申请 IP 地址证书

  • 根 CA 为GlobalSign,根 CA 的支持性和兼容性比Let's Encrypt

  • 支持安全性和性能更好的ECC 证书

  • 支持多域名泛域名证书申请(例如*.cestlavie.moe

  • 有效期为 90 天

  • 支持的 ACME 验证方式为TLS-ALPN-01HTTP-01、和 DNS-01

  • 暂不支持邮箱验证方式申请

  • 暂不支持国际化域名编码的域名

申请步骤

获取注册密钥

打开shell.cloud.google.com,输入以下代码

$ gcloud beta publicca external-account-keys create #创建凭据

回显为

$ gcloud beta publicca external-account-keys create
API [publicca.googleapis.com] not enabled on project [<projectid>]. Would you like to enable and retry (this will take a few minutes)? (y/N)?  y #允许创建 publica API
Enabling service [publicca.googleapis.com] on project [<projectid>]...
Operation "operations/acat.p2-<projectid>-<uuid>" finished successfully.
Created an external account key
[b64MacKey: <hmac_key>
keyId: <keyid>]

保存好输出的<hmac_key><keyid>,接下来要用

安装acme.sh

$ curl  https://get.acme.sh | sh -s   # 请确保已安装 curl

显示Install success!即为安装成功

使用凭据注册

$ acme.sh --set-default-ca --server google #切换默认 CA 为 Google
$ acme.sh --server https://dv.acme-v02.api.pki.goog/directory \
--register-account  --accountemail <Your_Email> --eab-kid <keyid> --eab-hmac-key <hmac_key> # 使用刚刚获取凭据注册账号

签发证书

  1. 使用 TXT 记录手动验证 DNS
$ acme.sh  --issue  --dns   -d yourdomain.com \
--yes-I-know-dns-manual-mode-enough-go-ahead-please

然后根据回显中

Add the following TXT record:
Domain: '_acme-challenge.yourdomain.com'
TXT value: '<TXT_value>'

设置 DNS 记录,完成后输入

$ acme.sh  --renew   -d yourdomain.com \
--yes-I-know-dns-manual-mode-enough-go-ahead-please

完成证书申请

显示Cert success即为申请成功

可以在~/.acme.sh/yourdomain.com/下获取证书

  1. 使用 Cloudflare API 自动验证 DNS1

首先获取你的Global API Key可在此处获取

然后在终端中输入

$ export CF_Key='<YourGlobalAPIKey>'
$ export CF_Email="<YourEmail>"

接下来申请证书,输入

$ acme.sh --issue --dns dns_cf -d yourdomain.com #单域名
$ acme.sh --issue --dns dns_cf -d *.yourdomain.com #泛域名
$ acme.sh --issue --dns dns_cf -d sub1.yourdomain.com -d sub2.yourdomain.com #多域名
$ acme.sh --issue --dns dns_cf -d yourdomain.com --ecc #ECC 证书

看到回显Cert success即为申请成功,可以在~/.acme.sh/yourdomain.com/下获取证书

  • 此时 Cloudflare 凭据会自动存储至~/.acme.sh/account.conf用于续期目的

附:申请下的证书路径

文中部分信息已做脱敏处理


参考文献

  1. acme.sh Wiki - github.com

  2. Automate Public Certificates Lifecycle Management via RFC 8555 (ACME) - google.com


  1. 这里默认使用了 Cloudflare 来演示自动申请证书,详细的支持列表及申请方法可以在这里找到 ↩︎