Featured image of post Google Trust Services 免费 90 天 SSL 证书 ACME.sh 申请教程

Google Trust Services 免费 90 天 SSL 证书 ACME.sh 申请教程

谷歌近期开始提供免费 SSL 证书申请,证书有效期最长为 90 天。可在填表加入测试计划后,通过 acme.sh 脚本申请签发。

据消息:

Google 提供免费公共证书服务

该功能处于内测阶段,Google 公告 (https://cloud.google.com/blog/products/identity-security/automate-public-certificate-lifecycle-management-via--acme-client-api) 说证书管理器预览版的增强功能现在可以用于 Google Cloud 客户网络负载均衡器的 TLS 终止或者跨云和内部部署的工作负载。

证书服务的特性如下(V2EX ZeroClover 提供)

  1. 免费,且仅支持 ACME 协议进行申请
  2. 和 Let’s Encrypt 一样支持多域名和泛域名
  3. 支持 IP 证书,但是目前仅限 IP Block 的所有者进行验证
  4. 目前不提供完整 ECDSA 链,只有叶证书是 ECDSA 的
  5. 目前不支持 Punycode 域名
  6. 证书有效期在 1 - 90 天内可选,但是目前 ACME 客户端似乎都还不支持设置证书有效期

1.申请开通 API

目前该服务处于 Preview 期,需要填表申请测试。

该服务为 Google Cloud 下的一个 API,需先在谷歌云控制台创建一个服务后方可使用。

谷歌云控制台:https://console.cloud.google.com

创建项目,记录项目 ID。本例中为exalted-shape-348002

打开谷歌官方的申请表单:https://docs.google.com/forms/d/e/1FAIpQLSd8zUIww_ztyT9a56OPq9NXISiyw6Y9g8S7LBtRQjxPhsHz5A/viewform?ts=620a6854

填入必要的信息,其中 Project ID 即为方才创建项目时显示的项目 ID。

邮箱建议填写自己的域名邮箱或谷歌邮箱,确保能收到谷歌官方的邮件。

约 1~2 天内,即可收到回复邮件。

此时进入谷歌云控制台,点击该项目,在侧边栏选择「API 和服务」,「已启用的 API 和服务」。在页面中点击「+启用 API 和服务」按钮。

选择图中的项目打开,点击「启用」。

2.获取 EAB

acme.sh 通过 ACME 方式与谷歌的签发服务通信,需要提供自己账户的 EAB(External Account Binding)。

在谷歌云控制台右上角点击「激活 Cloud Shell」按钮。

在其中输入如下命令:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
gcloud config set project exalted-shape-348002
# exalted-shape-348002 修改为你的实际项目ID

gcloud projects add-iam-policy-binding exalted-shape-348002 \
  --member=user:[email protected] \
  --role=roles/publicca.externalAccountKeyCreator
# exalted-shape-348002 修改为你的实际项目ID,[email protected] 修改为你的谷歌邮箱地址

gcloud alpha publicca external-account-keys create
# 创建EAB

共三条命令,最后一条命令执行后会显示 Key 的 ID(keyId)与密钥(b64MacKey)。

3.使用 acme.sh 申请证书

谷歌 ACME API 在国内机器无法连接,请使用国外 VPS。或配置 proxychains 等。

acme.sh 详细使用教程请参见 wiki:https://github.com/acmesh-official/acme.sh/wiki

在 VPS 上运行:

1
2
3
4
acme.sh --register-account -m [email protected] --server google \
    --eab-kid aaaaaaaaaa \
    --eab-hmac-key bbbbbbbb
# [email protected] 修改为你的谷歌邮箱地址,aaaaaaaaaa修改为刚刚申请的keyId,bbbbbbbb修改为刚刚申请的b64MacKey

最后根据 acme.sh 的基础使用操作签发证书即可。在签发时,使用--server google指定证书签发机构为谷歌。

效果:

4.参考资料

acme.sh 的文档:https://github.com/acmesh-official/acme.sh/wiki/Google-Public-CA

谷歌官方的文档:https://cloud.google.com/blog/products/identity-security/automate-public-certificate-lifecycle-management-via--acme-client-api

Licensed under CC BY-NC-SA 4.0