使用 Certbot 申请 Google 泛域名 ECC 证书

Google Trust Services Public Certificate Authority API lets you directly and programmatically request publicly trusted TLS certificates. These TLS certificates are trusted by major browsers, operating systems, and applications.

#Google · #SSL

2022 - 04 - 19

申請 Google Trust Services Public Certificate Authority API 權限

通过链接 https://docs.google.com/forms/d/e/1FAIpQLSd8zUIww... 开始填写申请表。完成提交后等待一封名为 Welcome to Google Cloud Certificate Manager, Public CA 的通知邮件,你便可以追随下列步骤。

部署過程

在 Google Cloud Platform 中打开 CloudShell 控制台,执行 gcloud config set project 项目ID 命令切换至你在申请表内填写的项目 ID,输入 gcloud services enable publicca.googleapis.com 启用 Public CA API,继续输入 gcloud beta publicca external-account-keys create 申请 密钥ID 与 b64MacKey。

以 Ubuntu20.04 系统为例,使用 apt install certbot 命令安装 certbot 后注册 ACME 账户。


certbot register \
  --email "你的邮箱地址" \
  --no-eff-email \
  --server "https://dv.acme-v02.api.pki.goog/directory" \
  --eab-kid "你申请的密钥ID" \
  --eab-hmac-key "你申请的b64MacKey"

完成注册后执行 openssl ecparam -genkey -name secp384r1 | openssl ec -out ecc.keyopenssl req -new -sha384 -key ecc.key -nodes -out ecc.csr -outform pem 命令生成 key 和 csr 文件。你也可以选择使用 CSR在线生成工具 https://myssl.com/csr_create.html 将生成的 CSR 与 KEY 内容以文件类型保存在 root 目录下。

接着进行申请证书,下列命令中将 --domains 的值更改为你生成 CSR 时填写的域名,因选择使用 dns-01 方式验证,要注意提示需在 DNS记录 中添加 TXT记录。顺利通过验证并申请成功后,会有提示指明完整证书链文件存在的位置。


  certbot certonly \
  --manual \
  --csr=你生成的csr文件 \
  --preferred-challenges "dns-01" \
  --server "https://dv.acme-v02.api.pki.goog/directory" \
  --domains "xajh.org" \
  --domains "*.xajh.org"