
























Google Cloud 在三月底也推出了通过 Automatic Certificate Management Environment(也就是我们常说的 acme 协议)实现的自动化证书管理服务。这也意味着我们现在可以免费申请到和 Let’s Encrypt 一样的 Google 公共证书了,主要特性如下:
而 acme.sh 更新也很快,第二天就进行了增加了对 Google Public CA 的支持,下面就简单分享下使用 acme.sh 申请 Google 公共证书的流程。
注:虽然 OCSP 在国内可用,但国内访问不了 Google CA 的 ACME Server,因此暂时无法在国内服务器上申请签发该证书。
我前面写过一篇文章 使用acme.sh自动签发和更新证书,如果你需要了解 acme.sh 的使用或者申请 Let’s Encrypt 证书的话可以参考一下。
首先你需要拥有一个 Google Cloud Platform(GCP)账号。
Updated 2023-12-16: Google Public CA 已于 2023 年 5 月结束内测,所有拥有 GCP 账号的用户都可以免费使用 GTS ACME API,不再需要申请资格,可以跳过这一步。
目前(2022 年 4 月 15 日)仍处于内测阶段,需要填写一个表单申请该功能,否则直接申请的话会提示错误:
(gcloud.alpha.publicca.external-account-keys.create) NOT_FOUND: Method not found.
其中需要填写你的 Google Cloud Project ID *,可以在你的控制台面板菜单栏左上角点击你的项目名查看:
我在提交一天后也没收到消息,看网友都是几小时就收到了…就又提交了一次,最后花了三天才收到了开通成功的邮件提醒:
启动:
或者直接在下一步的 Cloud Shell 中使用下面的命令启动也可以:
gcloud services enable publicca.googleapis.com
激活 Cloud Shell,输入下面内容选中项目,如果你只有一个项目的话可以跳过这步,会自动设置为唯一项目:gcloud config set project [project ID]
或者先使用下面的命令创建一个项目然后再选择该项目:
gcloud projects create [project ID]
gcloud config set project [project ID]
gcloud publicca external-account-keys create
中途弹窗点击授权之后会返回下列格式的信息,记录下来后面会用到:
Created an external account key
[b64MacKey: xxxxxxxxxxxxxxxxxxxxxxx
keyId: xxxxxxxxxxxxxxx]
* 获取的 EAB 密钥 7 天内有效,超过 7 天未使用该密钥会失效,注册的 ACME 帐号没有有效期。
默认以 root 用户进行操作演示。
curl https://get.acme.sh | sh
若后面出现 command not found,则需要手动执行以下命令:
source ~/.bashrc
这里以使用 Cloudflare 的 API 为例,通过 DNS 验证申请 Apex 域名和通配符(example.com 和 *.example.com)证书。
export CF_Token="xxxxxxxxxxxxxxxxxxxxxxxx"
export CF_Account_ID="xxxxxxxxxxxxxxxxxxxxxxxx"
export CF_Zone_ID="xxxxxxxxxxxxxxxxxxxxxxxx"
其中 CF_Token 为你获取到的 API 密钥,CF_Account_ID 和 CF_Zone_ID 可以在你域名概述页面侧边栏的 API 分栏看到。
acme.sh --register-account -m [邮箱] --server google \
--eab-kid [申请到的 keyId] \
--eab-hmac-key [申请到的 b64MacKey]
我在第一次注册的时候提示错误:
Please refer to https://curl.haxx.se/libcurl/c/libcurl-errors.html for error code: 6
无法解析 host,想了下应该是我的 acme.sh 是很久以前安装的,没有开启自动更新,使用 acme.sh --upgrade 命令更新一下就好了,或者将上面的 --server google 改成 --server https://dv.acme-v02.api.pki.goog/directory 手动指定服务器。
acme.sh --set-default-ca --server google
acme.sh --issue --dns dns_cf -d example.com -d *.example.com --keylength 2048
* 签发 ECC 证书:
acme.sh --issue --dns dns_cf -d example.com -d *.example.com --keylength ec-256
acme.sh --install-cert -d example.com \
--key-file /path/to/ssl/private.key \
--fullchain-file /path/to/ssl/fullchain.pem \
--capath /path/to/ssl/ca.pem \
--reloadcmd "service nginx reload"
* 安装 ECC 证书:
acme.sh --install-cert -d example.com --ecc \
--key-file /path/to/ssl/ecc_private.key \
--fullchain-file /path/to/ssl/ecc_fullchain.pem \
--capath /path/to/ssl/ecc_ca.pem \
--reloadcmd "service nginx reload"
最后贴一张 Google 公共证书的证书路径:
体验下来挺不错的,如果将来国内 OCSP 节点不会被搞的话就更好了。
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。