certbot-autoが1.3.0から1.5.0に勝手にアップグレードされてた

  • Certbot
  • Let's Encrypt
  • TLS

この記事は、構成と文章の整理にAIを使っています。
あくまで読みやすくするための補助で、内容そのものをAIにすべて任せて書いているわけではありませんが、ところどころ相談しながら整えています。

certbot-auto renew --force-renew --debug を実行したら、証明書の更新前にcertbot-auto自体が1.3.0から1.5.0に勝手にアップグレードされてた。ログはこんな感じ。

$ sudo /usr/local/certbot/certbot-auto renew --force-renew --debug
/usr/local/certbot/certbot-auto has insecure permissions!
To learn how to fix them, visit https://community.letsencrypt.org/t/certbot-auto-deployment-best-practices/91979/
Upgrading certbot-auto 1.3.0 to 1.5.0...
Replacing certbot-auto...
Creating virtual environment...
Installing Python packages...
Installation succeeded.
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Processing /etc/letsencrypt/renewal/a.example.jp.conf
Plugins selected: Authenticator webroot, Installer None
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for a.example.jp
Waiting for verification...
Cleaning up challenges
new certificate deployed without reload, fullchain is /etc/letsencrypt/live/a.example.jp/fullchain.pem
Congratulations, all renewals succeeded.
The following certs have been renewed:
/etc/letsencrypt/live/a.example.jp/fullchain.pem (success)

insecure permissionsの警告について

certbot-auto has insecure permissions! は証明書更新の失敗とは関係ない。certbot-auto本体(スクリプトファイル)のパーミッションがrootだけでなく他ユーザーからも書き換え可能になっている場合に出る警告らしい。放置していても更新自体は動くけど、サーバの他ユーザーがcertbot-autoを不正に書き換えて悪意あるコードを混入できてしまうリスクがあるとのこと。

対処は単純で、所有者をrootにしてパーミッションを絞ればいい。

chown root:root /usr/local/certbot/certbot-auto
chmod 0755 /usr/local/certbot/certbot-auto

1.3.0 → 1.5.0の自動アップグレードについて

certbot-autoは実行のたびに最新版のチェックをしていて、古いバージョンを使っていると自動で本体を差し替えてから処理を続ける。今回のログだと、仮想環境を作り直してPythonパッケージを再インストールしてから証明書更新に入っている。

バージョンの並びを見てみると、1.5.0は2020年6月2日リリースで、次の1.6.0は7月7日リリース。つまり6月22日時点では1.5.0が最新版で間違いない。1.3.0からのアップグレード幅も特に不自然ではなく、しばらくcertbot-autoを更新せずに放置していたサーバだったんだと思う(実機の運用履歴までは確認していないので、あくまで推測)。

更新後の証明書について

Installer None になっているのはwebrootプラグインを使っているケースで、Webサーバの設定リロードを自動ではやらない構成。なので new certificate deployed without reload という文言が出ている。ここは証明書ファイルだけ更新して、リロードは別途手動かcronの別処理に任せている運用なんだろう。