プログラマーのメモ書き

伊勢在住のプログラマーが気になることを気ままにメモったブログです

Let's Encrypt のプロトコルを ACME v1 -> ACME v2 に変更しました

少し前に、 Let's Encrypt から下記のようなメールが来てました。

Hi,

According to our records, the software client you're using to get Let's 
Encrypt TLS/SSL certificates issued or renewed at least one HTTPS certificate 
in the past two weeks using the ACMEv1 protocol. Here are the details of one 
recent ACMEv1 request from each of your account(s):

Client IP address:  xxx.xxx.xxx.xxx

User agent:  CertbotACMEClient/0.23.0 (certbot; Ubuntu 18.04.2 LTS) Authenticator/webroot Installer/None (renew; flags: n) Py/3.6.8 

Hostname(s):  "xxxxx.example.com" 

Request time:  2020-04-17 05:28:17 UTC 

Beginning June 1, 2020, we will stop allowing new domains to validate using 
the ACMEv1 protocol. You should upgrade to an ACMEv2 compatible client before 
then, or certificate issuance will fail. For most people, simply upgrading to 
the latest version of your existing client will suffice. You can view the 
client list at: https://letsencrypt.org/docs/client-options

If you're unsure how your certificate is managed, get in touch with the 
person who installed the certificate for you. If you don't know who to 
contact, please view the help section in our community forum at 
https://community.letsencrypt.org/c/help and use the search bar to check if 
there's an existing solution for your question. If there isn't, please create 
a new topic and fill out the help template.

ACMEv1 API deprecation details can be found in our community forum: 
https://community.letsencrypt.org/t/end-of-life-plan-for-acmev1

As a reminder: In the future, Let's Encrypt will be performing multiple 
domain validation requests for each domain name when you issue a certificate. 
While you're working on migrating to ACMEv2, please check that your system 
configuration will not block validation requests made by new Let's Encrypt IP 
addresses, or block multiple matching requests. Per our FAQ 
(https://letsencrypt.org/docs/faq), we don't publish a list of IP addresses 
we use to validate, and this list may change at any time.

To receive more frequent updates, subscribe to our API Announcements: 
https://community.letsencrypt.org/t/about-the-api-announcements-category 

Thank you for joining us on our mission to create a more secure and privacy-
respecting Web!

All the best,

Let's Encrypt

どうも、

Let's Encrypt の更新で使っているプロトコル ACME v1 が古いので ACME v2 に変更してください。 変更しないと更新できなくなりますよ。

ということのようです(2020/6/1という日付は、 ACME v1 での新規ドメインの受付を停止する期日なので、すぐさま更新できなくなるわけではないようです)。

ということなので、 ACME v2 を使うようにしてみます。

certbot の更新

上記のメールを読むと、クライアント(こちらの記事でセットアップした Rainloop のサーバーなので、クライアントは certbot になります)を更新すればOKだよ、とあるので、とりあえず更新してみます。

現在の certbot のバージョンが 0.23.0 だったので、

ubuntu@ip-xxx-xxx-xxx-xxx:~$ apt list --upgradable | grep -i cert 

で確認すると certbot のバージョンは 0.27 でした。

これもちょっと古いっぽいです。

ソースコードから入れなきゃいけないのかなと思いつつもうちょっと調べてみると、 certbot の提供元のサイトで OS とWebサーバーを入力したら、PPA を追加したら最新版が使えそうなことがわかりました。

Certbot - Ubuntubionic Apache

追加してみます。

ubuntu@ip-xxx-xxx-xxx-xxx:~$ sudo add-apt-repository ppa:certbot/certbot
 This is the PPA for packages prepared by Debian Let's Encrypt Team and backported for Ubuntu.

Note: Packages are only provided for currently supported Ubuntu releases.
 詳しい情報: https://launchpad.net/~certbot/+archive/ubuntu/certbot
[ENTER] を押すと続行します。Ctrl-c で追加をキャンセルできます。

ヒット:1 http://archive.ubuntulinux.jp/ubuntu bionic InRelease
ヒット:2 http://archive.ubuntulinux.jp/ubuntu-ja-non-free bionic InRelease                                                                                                             
ヒット:3 http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu bionic InRelease                                                                                                          
ヒット:4 http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu bionic-updates InRelease                                                                                                  
ヒット:5 http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu bionic-backports InRelease                                
取得:6 http://ppa.launchpad.net/certbot/certbot/ubuntu bionic InRelease [21.3 kB]                                      
ヒット:7 http://security.ubuntu.com/ubuntu bionic-security InRelease                         
取得:8 http://ppa.launchpad.net/certbot/certbot/ubuntu bionic/main amd64 Packages [8,032 B]  
取得:9 http://ppa.launchpad.net/certbot/certbot/ubuntu bionic/main Translation-en [4,176 B]
33.5 kB を 2秒 で取得しました (19.4 kB/s)                      
パッケージリストを読み込んでいます... 完了
ubuntu@ip-xxx-xxx-xxx-xxx:~$ 

確認してみます。

ubuntu@ip-xxx-xxx-xxx-xxx:~$ sudo apt update
ubuntu@ip-xxx-xxx-xxx-xxx:~$ apt list --upgradable | grep certbot

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

certbot/bionic 0.31.0-1+ubuntu18.04.1+certbot+1 all [0.23.0-1 からアップグレード可]
python3-acme/bionic 0.31.0-2+ubuntu18.04.3+certbot+2 all [0.22.2-1ubuntu0.1 からアップグレード可]
python3-certbot/bionic 0.31.0-1+ubuntu18.04.1+certbot+1 all [0.23.0-1 からアップグレード可]
python3-configobj/bionic 5.0.6-2+ubuntu18.04.1+certbot+1 all [5.0.6-2 からアップグレード可]
python3-future/bionic 0.15.2-4+ubuntu18.04.1+certbot+3 all [0.15.2-4ubuntu2 からアップグレード可]
python3-josepy/bionic 1.1.0-2+ubuntu18.04.1+certbot+1 all [1.1.0-1 からアップグレード可]
python3-parsedatetime/bionic 2.4-3+ubuntu18.04.1+certbot+3 all [2.4-2 からアップグレード可]
python3-zope.component/bionic 4.3.0-1+ubuntu18.04.1+certbot+3 all [4.3.0-1 からアップグレード可]
python3-zope.hookable/bionic 4.0.4-4+ubuntu18.04.1+certbot+1 amd64 [4.0.4-4build4 からアップグレード可]
python3-zope.interface/bionic 4.3.2-1+ubuntu18.04.1+certbot+1 amd64 [4.3.2-1build2 からアップグレード可]
ubuntu@ip-xxx-xxx-xxx-xxx:~$ 

0.31.0 が使えるようです。

certbot の更新

本当は certbot だけ更新すればよかったのですが、何を思ったか勢い余って、

ubuntu@ip-xxx-xxx-xxx-xxx:~$ sudo apt upgrade

でシステム全体のアップグレードをしてしまいました。我ながらイケてないですね。

一応、書いておくと、アップグレード中に

設定ファイル '/etc/cron.d/certbot'
 ==> これはインストールしてから (あなたかスクリプトによって) 変更されています。
 ==> パッケージ配布元が更新版を提供しています。
   どうしますか? 以下の選択肢があります:
    Y か I  : パッケージメンテナのバージョンをインストールする
    N か O  : 現在インストールされている自分のバージョンを残す
      D     : 両バージョンの差異を表示する
      Z     : 状況を調査するためにシェルを開始する
 デフォルトでは現在使っている自分のバージョンを残します。
*** certbot (Y/I/N/O/D/Z) [デフォルト=N] ? 

と聞かれたので、デフォルトのNを選びました。

更新した certbot のバージョンを確認すると

ubuntu@ip-xxx-xxx-xxx-xxx:~$ certbot --version
certbot 0.31.0
ubuntu@ip-xxx-xxx-xxx-xxx:~$ 

無事 0.31.0 になっているようでした。

ACME v2 を利用していることの確認

さて、これで本当に問題ないのか不安です。そこで、 ACME v2 を使っている確認を行ってみました。

Let's Encrypt のサイトに下記の記述があり

Update your client software to continue using Let's Encrypt - Help - Let's Encrypt Community Support

--dry-run 付で renew を実行して、v2 のステージング環境につながっていればよいような感じです。

日本語の記事もありました。

Let’s EncryptのCertbot向けACMEv2対応手順(Update your client software to continue using Let’s Encrypt) – 株式会社ルーター

試してみます。

ubuntu@ip-xxx-xxx-xxx-xxx:~$ sudo certbot renew --force-renew --dry-run --webroot-path /var/www/html/ドキュメントルート
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/xxxxx.example.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Plugins selected: Authenticator webroot, Installer None
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for xxxxx.example.com
Using the webroot path /var/www/html/ドキュメントルート for all unmatched domains.
Waiting for verification...
Cleaning up challenges

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
new certificate deployed without reload, fullchain is
/etc/letsencrypt/live/xxxxx.example.com/fullchain.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
** DRY RUN: simulating 'certbot renew' close to cert expiry
**          (The test certificates below have not been saved.)

Congratulations, all renewals succeeded. The following certs have been renewed:
  /etc/letsencrypt/live/ドメイン名/fullchain.pem (success)
** DRY RUN: simulating 'certbot renew' close to cert expiry
**          (The test certificates above have not been saved.)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ubuntu@ip-xxx-xxx-xxx-xxx:~$ 

ログを確認します。

Server: nginx
Date: Wed, 13 May 2020 12:49:22 GMT
Content-Type: application/pem-certificate-chain
Content-Length: 3567
Connection: keep-alive
Cache-Control: public, max-age=0, no-cache
Link: <https://acme-staging-v02.api.letsencrypt.org/directory>;rel="index"

こんな感じで、 acme-staging-v02 とあるので、大丈夫そうな感じです。

証明書の更新が行われたら、再度確認してみようと思います。