MAGAZINE
ルーターマガジン
Let’s EncryptのCertbot向けACMEv2対応手順(Update your client software to continue using Let's Encrypt)

お久しぶりです、Sakaeです。前回記事から少し間があいてしまいました。
「Update your client software to continue using Let's Encrypt」という件名のメールがやってきた
今年に入ってから、Let's Encriptより「Update your client software to continue using Let's Encrypt」というメールが来るようになったかたがいると思います。僕も私用のメールボックスにこのようなメールが何通も入るようになりました。
内容を要約すると、証明書自動発行のためのプロトコル(ACME:Automated Certificate Management Environment)をバージョンアップするために、証明書更新クライアントをアップデートしてくださいという通知です。ご丁寧にドメインやサーバーのIPアドレス、ACME更新のリクエストを行っているクライアント(Certbotなど)の種類まで通知してくれています。
突然証明書の期限が切れてしまっては問題ですので、このメールが来たかた向けにACMEv1からACMEv2へアップデートするための手順をご紹介します。(ただしCertbot向けですので別のクライアントをお使いの場合は参考にならないかもです。)
明示的にCertbotにACMEv2で更新を行わせる方法
まだACMEv1による証明書更新を行っているか事前テスト
まずは、自分のLet's Encript証明書更新クライアントがACMEv1で通信をしていることを確認しましょう。テスト駆動開発(TDD)でいうレッドの手順です。
certbot renew
コマンドには--dry-run
オプションをつけることで、証明書更新のステージングサーバーに証明書更新をリクエストして、実際に証明書の更新を行わずに更新プロセスをシミュレーションするドライランモードがついています。
以下のコマンドを実行しましょう。DRY RUN: simulating
の記述とともに、証明書更新のシミュレーションが行われます。
# certbot renew --dry-run
Saving debug log to /var/log/letsencrypt/letsencrypt.log
-------------------------------------------------------------------------------
Processing /etc/letsencrypt/renewal/dontlookatme.com.conf
-------------------------------------------------------------------------------
Cert not due for renewal, but simulating renewal for dry run
Starting new HTTPS connection (1): acme-staging.api.letsencrypt.org
Attempting to renew cert from /etc/letsencrypt/renewal/dontlookatme.com.conf produced an unexpected error: urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Account creation on ACMEv1 is disabled. Please upgrade your ACME client to a version that supports ACMEv2 / RFC 8555. See https://community.letsencrypt.org/t/end-of-life-plan-for-acmev1/88430 for details.. Skipping.
** DRY RUN: simulating 'certbot renew' close to cert expiry
** (The test certificates below have not been saved.)
All renewal attempts failed. The following certs could not be renewed:
/etc/letsencrypt/live/dontlookatme.com/fullchain.pem (failure)
** DRY RUN: simulating 'certbot renew' close to cert expiry
** (The test certificates above have not been saved.)
1 renew failure(s), 0 parse failure(s)
上記コマンドを実行することで、/var/log/letsencrypt/letsencrypt.log
に詳細なデバッグログが含まれるログが出力されますので 内容を確認してください。certbot renew
のリクエスト先がhttps://acme-staging.api.letsencrypt.org/directory.
である場合はACMEv2への対応が必要となる可能性があります。(余談ですが、リクエスト先API URIにstagingと記載があることからも、ドライランでステージング環境に接続されていることも見て取れます。)
# less /var/log/letsencrypt/letsencrypt.log
〜〜〜略〜〜〜
2020-04-22 05:53:44,897:DEBUG:acme.client:Sending GET request to https://acme-staging.api.letsencrypt.org/directory.
〜〜〜略〜〜〜
2020-04-22 05:53:45,825:WARNING:certbot.renewal:Attempting to renew cert from /etc/letsencrypt/renewal/dontlookatme.com.conf produced an unexpected error: urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Account creation on ACMEv1 is disabled. Please upgrade your ACME client to a version that supports ACMEv2 / RFC 8555. See https://community.letsencrypt.org/t/end-of-life-plan-for-acmev1/88430 for details.. Skipping.
〜〜〜略〜〜〜
CertbotでLet’s encriptの証明書更新をACMEv2で行うように修正する
Certbotのバージョンが古すぎなければ、既存のCertbotでもすでにACMEv2プロトコルでの証明書更新が可能なケースが多いです。下記の公式コミュニティでもスレッドがありますが、Certbotに明示的にACMEv2プロトコルを使用するように設定することができます。
参考:How to update from ACMEv1 to ACMEv2 - Help - Let's Encrypt Community Support
もしかしたら後述の明示的な対応を行わなくても、ACMEv1のサポート停止後には自動的にACMEv2に切り替わるのかもしれませんが、明示的にきちんとACMEv2を利用するように設定して安心しておきたいかたは以下の設定を行いましょう。
下記の通り/etc/letsencrypt/renewal/dontlookatme.com.conf
というパスにある設定ファイルに、server = https://acme-v02.api.letsencrypt.org/directory
という行を追記するだけです。
※dontlookatme.com
の部分はダミードメイン名ですので、みなさんの環境に合わせて自分のドメイン名に置き換えてお考えください。
# vim /etc/letsencrypt/renewal/dontlookatme.com.conf
# renew_before_expiry = 30 days
version = 0.14.1
archive_dir = /etc/letsencrypt/archive/dontlookatme.com
cert = /etc/letsencrypt/live/dontlookatme.com/cert.pem
privkey = /etc/letsencrypt/live/dontlookatme.com/privkey.pem
chain = /etc/letsencrypt/live/dontlookatme.com/chain.pem
fullchain = /etc/letsencrypt/live/dontlookatme.com/fullchain.pem
# Options used in the renewal process
[renewalparams]
authenticator = webroot
installer = None
account = 06a3ada638d260c9c01fb910435333ca
server = https://acme-v02.api.letsencrypt.org/directory <ーこの行を追加
[[webroot_map]]
dontlookatme.com = /root/www
Certbot renewコマンドでACMEv2プロトコルでの証明書更新ができているか事後テスト
上記confファイルに設定を追加後、再度ドライランを実行してログを確認してみます。
# certbot renew --dry-run
# less /var/log/letsencrypt/letsencrypt.log
〜〜〜略〜〜〜
2020-04-22 15:38:17,027:DEBUG:acme.client:Sending GET request to https://acme-staging-v02.api.letsencrypt.org/directory.
〜〜〜略〜〜〜
2020-04-22 15:38:21,201:DEBUG:certbot._internal.renewal:no renewal failures
〜〜〜略〜〜〜
GET request to https://acme-staging-v02.api.letsencrypt.org/directory
というように、v02とついたURIに証明書発行のリクエストが行われていればACMEv2を明示的に利用する設定が正しく反映されています。
Certbotが古すぎてACMEv2プロトコル利用明示設定ができない場合はCertbotをアップデート
上記手順でconfファイルにACMEv2プロトコル利用明示設定を行ってもなお、デバッグログに変わらず以下のようなACMEv1でのリクエスト先URLや、ACMEv1利用を止めてというwarningの文言が複数含まれる場合は、certbotのバージョンが古くACMEv2に対応できていない(--serverオプションが利用できない)と思われます。
# less /var/log/letsencrypt/letsencrypt.log
〜〜〜略〜〜〜
2020-04-22 05:53:44,897:DEBUG:acme.client:Sending GET request to https://acme-staging.api.letsencrypt.org/directory.
〜〜〜略〜〜〜
2020-04-22 05:53:45,825:WARNING:certbot.renewal:Attempting to renew cert from /etc/letsencrypt/renewal/dontlookatme.com.conf produced an unexpected error: urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Account creation on ACMEv1 is disabled. Please upgrade your ACME client to a version that supports ACMEv2 / RFC 8555. See https://community.letsencrypt.org/t/end-of-life-plan-for-acmev1/88430 for details.. Skipping.
〜〜〜略〜〜〜
参考:How to update to ACME v2 with old certbot installation - Help - Let's Encrypt Community Support
その場合は、以下のような手順でCertbot自体をバージョンアップしてください。yum
とapt
向けの更新手順をご紹介します。
CentOSなど向け:yumでcertbotをバージョンアップ
# yum update certbot
Ubuntuなど向け:aptでcertbotをバージョンアップ
# apt-get update
# apt-get install software-properties-common
# add-apt-repository universe
# add-apt-repository ppa:certbot/certbot
# apt-get update
# apt upgrade certbot
Certbotのバージョンアップを行った上で、上記のACMEv2プロトコル利用の明示設定を行えば大丈夫だと思います。
最後に
最後に、ACMEv1のサポート停止(ACMEv2)への切り替えについてのスケジュールについてですが、公式のコミュニティ発表によると、
参考:End of Life Plan for ACMEv1 - API Announcements - Let's Encrypt Community Support
- 2020年6月からACMEv1による新規ドメインの証明書発行が終了
- 2021年6月から証明書更新も含めてACMEv1のサポートが終了
というように言われています。
メールを読んだだけでは2020年6月に証明書更新の停止のように思えて慌てて対応手順を探しましたが、まだ猶予はあるようですので慌てなくても大丈夫そうです。ぜひ、本記事の情報がお役に立てばと思います。
CONTACT
お問い合わせ・ご依頼はこちらから