1. TOPTOP
  2. インフラ

“Action required: Let’s Encrypt certificate renewals”というメールがきたのでLet’s Encryptを”certbot renew –dry-run”コマンドでACME v2にする #letsencrypt

|

letsencrypt_certificate_renewals_0

2019年1月27日(日)にLet’s Encrypt Staffから”Action required: Let’s Encrypt certificate renewals“という件名でメールをいただきました。

Action may be required to prevent your Let’s Encrypt certificate renewals from breaking.

という文章でE-mailは始まります。かいつまんで説明すると、TLS-SNI-01のLet’s Encrypt証明書は、2019年2月13日(水)をもって一時的には使えなくなり、同年3月13日以降は完全に使えなくなるとのことです。

TLS-SNI-01のLet’s Encryptは使えなくなる

既存の証明書が使えなくなる理由は、Let’s Encryptが採用したTLS-SNI認証(新しいタブで開く)に脆弱性があったためです。

2018年の1月初旬にTLS-SNI認証チャレンジの脆弱性が発見され、さまざまな対策が取られたようですが、最終的にはTLS-SNI認証の開発は断念されたようです。その経緯についてはこちらのページ(新しいタブで開く)が参考になります。

そこでLet’s Encryptは、certbotコマンドを使用しているユーザーに対して、 ACME v2 staging environmentにアクセスするLet’s Encryptを使用するよう強く推奨(新しいタブで開く)しています。

ACME v2にアクセスするためのコマンド

以下はLet’s Encryptを、引き続き使用したい場合のコマンドです。ただしさまざまざページを参考にしているため、必ずしもこのコマンドが正しいとは言い切れません。他のページも参考にしながら実行してください。実行環境はCentOS7 + Apache2.4です。

certbotのアップデート

# yum update
# certbot --version
certbot 0.29.1

Let’s Encryptで証明しているドメインを使っているサーバーに対して、yumコマンドでアプリケーションのアップデートを行います。アップデートを行ったのちcertbotコマンドのバージョンを確認します。

既存の証明書(TLS-SNI-01)の使用を止めるために、certbotのバージョンは”0.28.1″もしくはそれ以上のバージョンが推奨(新しいタブで開く)されているためです。

テスト用のSSL/TLSサーバ証明書を取得

# certbot renew --dry-run

テスト用のSSL/TLSサーバ証明書をサブコマンドの”renew”と”–dry-run”を取得します。こちらのページを参考にして「テスト用」という単語を用いましたが、すでにLet’s Encryptのサイト(新しいタブで開く)でACME v2にアクセスする証明書を取得することが推奨されてます。したがって上記のコマンドをそのまま実行しても良いと考えられます。

# view /etc/letsencrypt/renewal/e-yota.com.conf

# renew_before_expiry = 30 days
version = 0.27.1
archive_dir = /etc/letsencrypt/archive/e-yota.com
cert = /etc/letsencrypt/live/e-yota.com/cert.pem
privkey = /etc/letsencrypt/live/e-yota.com/privkey.pem
chain = /etc/letsencrypt/live/e-yota.com/chain.pem
fullchain = /etc/letsencrypt/live/e-yota.com/fullchain.pem

# Options used in the renewal process
[renewalparams]
authenticator = apache
installer = apache
account = ***************************** ←(英数文字の羅列)
server = https://acme-v02.api.letsencrypt.org/directory

最後にLet’s Encryptの設定ファイルで内容を確認します。最後の行で”server = https://acme-v02.api.letsencrypt.org/directory”となっています。おそらくこの内容でもって、Let’s EncryptはACME v2 staging environmentにアクセスするものと考えられます。設定ファイルの読み方についてはQiitaの記事(新しいタブで開く)も参考になると思います。

手順を間違えたらどうなるか?

以下は”certbot renew –dry-run”を実行したときに感じた個人的な雑記です。読み飛ばしていただいても構いませんが、気になる方はご参考までに。

certbotコマンドを”0.27.1″の状態でACME v2にアクセス

実はcertbotコマンドのバージョンを”0.28.1″にしなければならないことは、”certbot renew –dry-run”を実行したあとに気がつきました。そのときのコマンドと出力結果は以下の通りです。

# certbot --version
certbot 0.27.1

# certbot renew --dry-run
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/e-yota.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cert not due for renewal, but simulating renewal for dry run
Plugins selected: Authenticator apache, Installer apache
Starting new HTTPS connection (1): acme-staging-v02.api.letsencrypt.org
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for e-yota.com
Waiting for verification...
Cleaning up challenges

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
new certificate deployed with reload of apache server; fullchain is
/etc/letsencrypt/live/e-yota.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/e-yota.com/fullchain.pem (success)
** DRY RUN: simulating 'certbot renew' close to cert expiry
**          (The test certificates above have not been saved.)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.

そのため、Let’s Encryptの設定ファイルが”version = 0.27.1″になってしまったのかもしれません。

改めてcertbotコマンドをアップデート

改めてcertbotコマンドのバージョンを”yum update”で”0.29.1″にした上で、再度”certbot renew –dry-run”を実行しました。出力結果は以下の通りです。

# certbot --version
certbot 0.29.1
[root@ik1-320-20212 ~]# certbot renew --dry-run
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/e-yota.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cert not due for renewal, but simulating renewal for dry run
Plugins selected: Authenticator apache, Installer apache
Starting new HTTPS connection (1): acme-staging-v02.api.letsencrypt.org
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for e-yota.com
Waiting for verification...
Cleaning up challenges
Resetting dropped connection: acme-staging-v02.api.letsencrypt.org

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
new certificate deployed with reload of apache server; fullchain is
/etc/letsencrypt/live/e-yota.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/e-yota.com/fullchain.pem (success)
** DRY RUN: simulating 'certbot renew' close to cert expiry
**          (The test certificates above have not been saved.)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

2回目の”renew”を実行すると”IMPORTANT NOTES:”以下の表示はされませんでした。

# view /etc/letsencrypt/renewal/e-yota.com.conf

# renew_before_expiry = 30 days
version = 0.27.1
archive_dir = /etc/letsencrypt/archive/e-yota.com
cert = /etc/letsencrypt/live/e-yota.com/cert.pem
privkey = /etc/letsencrypt/live/e-yota.com/privkey.pem
chain = /etc/letsencrypt/live/e-yota.com/chain.pem
fullchain = /etc/letsencrypt/live/e-yota.com/fullchain.pem

# Options used in the renewal process
[renewalparams]
authenticator = apache
installer = apache
account = ***************************** 
server = https://acme-v02.api.letsencrypt.org/directory

設定ファイルを再度確認すると、”version = 0.27.1″のままでした。

設定ファイルに記述されているバージョンを修正

# cp /etc/letsencrypt/renewal/e-yota.com.conf /etc/letsencrypt/renewal/e-yota.com.conf.org
# vi /etc/letsencrypt/renewal/e-yota.com.conf

# renew_before_expiry = 30 days
version = 0.29.1
archive_dir = /etc/letsencrypt/archive/e-yota.com
cert = /etc/letsencrypt/live/e-yota.com/cert.pem
privkey = /etc/letsencrypt/live/e-yota.com/privkey.pem
chain = /etc/letsencrypt/live/e-yota.com/chain.pem
fullchain = /etc/letsencrypt/live/e-yota.com/fullchain.pem

# Options used in the renewal process
[renewalparams]
authenticator = apache
installer = apache
account = ***************************** 
server = https://acme-v02.api.letsencrypt.org/directory

したがって元ファイルのコピーを取った上で”version = 0.27.1″を”0.29.1″に変更しました。もちろんこの処置で良いのかどうかは分かりません。この記事を読んでいただいた方の中から、あとに続く記事の公開を期待しています。

2019年2月9日(土)追記

サーバー管理に詳しい方に確認したところ”version”の記述は、”0.29.1″でも”0.27.1″でも証明書の更新について問題はないとの見解をいただきました。強いていうなら、元の”0.27.1″のままの方が分かりやいのではないかとご指摘を合わせていただきました。

# vi /etc/letsencrypt/renewal/e-yota.com.conf

# renew_before_expiry = 30 days
# version = 0.29.1 echizenya changed 20190209 )←コメントアウトした
version = 0.27.1
archive_dir = /etc/letsencrypt/archive/e-yota.com
cert = /etc/letsencrypt/live/e-yota.com/cert.pem
privkey = /etc/letsencrypt/live/e-yota.com/privkey.pem
chain = /etc/letsencrypt/live/e-yota.com/chain.pem
fullchain = /etc/letsencrypt/live/e-yota.com/fullchain.pem

...

今、自分の設定ファイルはこのような状態にしています。