Debian の Let's Encrypt (certbot) を --preferred-chain オプション対応済みのバージョンにしてDST Root CA X3を指定する
2020年9月末でAndroid 7.1以下でSSLが使えなくなるらしいので。
以下はDebian 10 Busterの環境だけれども、stretchでもCentOSでも内容はほとんど同じはず。
songmu.jp
community.letsencrypt.org
バージョン 1.6.0から --preferred-chain オプションで有効期限を一年延ばせる。
# certbot --version certbot 0.31.0
ただしパッケージで入れているとかなり古いバージョンのはず。
Satoshi Kojima: "そしてsudo certbot --preferred-chain "DST Root CA X3…" - sandbox : skoji
ソースから入れてもいいけど、依存関係で詰まったら嫌なのでsnapdというパッケージ管理ツールを使って最新版をインストールする。
念のため /etc/letsencrypt をコピー退避。
apt install snapd apt remove certbot python3-certbot-dns-sakuracloud apt autoremove
python3-certbot-dns-sakuracloud の箇所は、関連パッケージを入れているものに合わせてremove。
systemctl list-timers は消えたけど /etc/cron.d/certbot は残っている模様。
remove --purge していないので /etc/letsencrypt も残っている。
本家certbotマニュアルにしたがってsnapでcertbotをインストールする。
snap install --classic certbot
/etc/profile.d/apps-bin-path.sh にPATHが設定されているので、ログインし直す。
# certbot --version jq: error (at <stdin>:0): Cannot iterate over null (null)
うーん。。。
snapのcoreを入れる必要があるみたい。
Issues running certbot command - Help - Let's Encrypt Community Support
snap install core && snap refresh core
# certbot --version certbot 1.8.0
OK。core20とcoreは別物なのね。
古い設定が生きているか確認する。
certbot certificates
新しい設定 --preferred-chain を試したいところだけど、いくつかあるドメインのうち、更新が間近でないものは設定ファイルだけ変更したい。
community.letsencrypt.org
でも無理なようだ。ミスった場合に気付かないからだとか。
実行したらdnsパッケージを入れるのを忘れていたことに気付いた。
snap search certbot snap info certbot-dns-sakuracloud snap install --beta certbot-dns-sakuracloud
エラーが出た。
error: cannot perform the following tasks: - Run hook prepare-plug-plugin of snap "certbot" (run hook "prepare-plug-plugin": ----- Only connect this interface if you trust the plugin author to have root on the system Run `snap set certbot trust-plugin-with-root=ok` to acknowledge this and then run this command again to perform the connection -----)
snap set certbot trust-plugin-with-root=ok snap install --beta certbot-dns-sakuracloud
classicは要らない?snapの仕組みが分からないな…。
certbot renew --dry-run --force-renew --cert-name ドメイン名 --preferred-chain "DST Root CA X3"
dry-runで確認した後に実行。--cert-name でドメインの設定ファイルを指定する。
certbot renew --force-renew --cert-name ドメイン名 --preferred-chain "DST Root CA X3"
証明書は作り直さなくてもforce-renewalでOKぽい。
あくあーら@デブ鯖缶 (@aquarla@gochisou.dev) - ごちそうデブ
設定ファイルを見ると
preferred_chain = DST Root CA X3
が追記されていた。
設定を間違った場合の動作がまだ確認できないけれど、今はこれで良しとする。
crontabの設定は /usr/bin/certbot が存在しない(/snap/bin/certbot にある)し、systemdのタイマーには新しい版が登録されているのでcronは実行されないはず。ひとまず放置で。