certbotを使ってGoogle Public CAの無料証明書を発行する

こんにちは、tukapiyoです。

これまで、Let’s Encryptを使ってTLSサーバ証明書を発行してきましたのですが、今回Google Cloud(Google Public CA)の証明書も利用することにしました。
その手順についてまとめてみます。

経緯

というのも、証明書は公開サーバだけではなくて、VyOSのAPIやIKEv2 VPNでも使用していたのですが、今月(2026年7月)発行した証明書から、VyOSでは証明書チェーンの検証が行えなくなってしまったのです。
(現在の)VyOSでは、APIやVPN設定において、証明書チェーンの検証は1段のみ(証明書+1つ上のCA証明書のみ)可能となっています。
証明書チェーンを登録しても2段目以降は無視される仕様で、チェーンが深いと接続元クライアントが証明書を信頼できなくなってしまうようです。
この事象は報告や改修も進んでいるようなので、いずれは解消するかもしれません。

しかし、VyOSの改修版が出るのは当面先でしょうから、証明書自体を変えることにしてみました。

やること

旧:certbotでdns-01チャレンジを使って、Let’s Encryptの証明書を発行
新:certbotでdns-01チャレンジを使って、Google Cloud(Google Public CA)の証明書を発行
に変更していきます。

なお、dns-01チャレンジはAWSのRoute 53を活用しています。
この場合のAWSの設定等は以下の記事を参考にして下さい。

Proxmox VEのサーバ証明書をLet’s Encryptで取得する(Route 53+dns-01)

手順

基本的にはGoogle Cloudのドキュメントに沿って進めます。

IAMロールの設定

roles/publicca.externalAccountKeyCreatorロールを与える必要があります。
が今回、オーナーロールをそのまま使いますので特に対応不要です。

Public CA APIを有効化

以下のコマンドでAPIを有効化します。

$ gcloud services enable publicca.googleapis.com

EABシークレットの発行

EABシークレットを発行します。
EABシークレットは、EABキーとHMACで構成されています。

$ gcloud publicca external-account-keys create

ACMEアカウント登録

上記で発行したEABシークレットを利用して、Google Public CAにACMEアカウントを登録します。

今回はLinux上でcertbotを実行します。
Let’s Encryptのときには不要だった、--serverパラメータを利用してGoogle Public CAのACMEディレクトリを指定します。

# certbot register --email "<メールアドレス>" --no-eff-email --server "https://dv.acme-v02.api.pki.goog/directory" --eab-kid "<EABキー>" --eab-hmac-key "<HMAC>"
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at: https://pki.goog/GTS-SA.pdf
You must agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y
Account registered.

Account registered.と表示されれば問題ありません。

ACMEアカウントの確認

登録されたアカウントを確認するにはshow_accountを実行します。
前回同様に--serverパラメータを利用します。

# certbot show_account --server "https://dv.acme-v02.api.pki.goog/directory"
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Account details for server https://dv.acme-v02.api.pki.goog/directory:
  Account URL: https://dv.acme-v02.api.pki.goog/account/..(snip)..
  Account Thumbprint: ..(snip)..
  Email contact: ..(snip)..

証明書発行

dns-01チャレンジ(Route 53と連携)を利用して証明書を発行します。
冒頭に記載したとおり、既にLet’s Encryptで証明書を発行しているため(有効期限がまだ余裕があるため)、再発行するかどうか確認されますが気にせず再発行します。

# certbot certonly --dns-route53 --agree-tos --server "https://dv.acme-v02.api.pki.goog/directory" --domains "<FQDN>"
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Certificate not yet due for renewal

You have an existing certificate that has exactly the same domains or certificate name you requested and isn't close to expiry.
(ref: /etc/letsencrypt/renewal/..(snip)..)

What would you like to do?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: Keep the existing certificate for now
2: Renew & replace the certificate (may be subject to CA rate limits)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Renewing an existing certificate for ..(snip)..

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/..(snip)../fullchain.pem
Key is saved at:         /etc/letsencrypt/live/..(snip)../privkey.pem
This certificate expires on 2026-10-16.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
 * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
 * Donating to EFF:                    https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Successfully received certificate.と表示されれば完了です。

証明書の確認

証明書の確認自体は、以下の様にcertificatesを実行すれば良いのですが…

# certbot certificates
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Found the following certs:
  Certificate Name: <FQDN>
    Serial Number: ..(snip)..
    Key Type: ECDSA
    Domains: <FQDN>
    Expiry Date: 2026-10-16 06:31:34+00:00 (VALID: 89 days)
    Certificate Path: /etc/letsencrypt/live/<FQDN>/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/<FQDN>/privkey.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

今回Google Public CAを利用できていることを確認するため、設定ファイルを直接確認します。

# cat /etc/letsencrypt/renewal/<FQDN>.conf
..(snip)..
[renewalparams]
account = ..(snip)..
authenticator = dns-route53
server = https://dv.acme-v02.api.pki.goog/directory
key_type = ecdsa

こんな感じで、serverにGoogle Public CAのACMEディレクトリが記載されていれば問題ありません。

(Let’s EncryptのACMEディレクトリは、https://acme-v02.api.letsencrypt.org/directoryです。)

結果

Google Public CAの証明書に切り替えた後、VyOSでも問題なく検証できるようになりました。
めでたしめでたし。

おすすめ

コメントを残す