2021年10月2日
何やら、趣味で運営している「iOSの買い物アプリ」向けに稼働させているAPI通信がSSLでエラーになっている。
エラー詳細はキャプチャ撮り忘れなので割愛しますが、調べたところ「Let'sEncryptのルート証明書変更への対応」が必要だった。
この対応を「certbot」の設定変更で対応したのでその備忘録。
誰かの役に立てれば幸いです。
対応方法
「certbot 1.6」以降のバージョンであれば「--preferred-chain」オプションを利用することで対応が可能。
OSバージョン確認
$ cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
#certbotのバージョン確認
#certbot 1.6以降のバージョンであれば「--preferred-chain」が利用可能
$ sudo certbot --version
certbot 1.11.0
対応方法1
certbot renewコマンド実行の際にオプション指定する
#dryrun
$ sudo certbot renew --dry-run --force-renewal --preferred-chain "ISRG Root X1"
#execute
$ sudo certbot renew --force-renewal --preferred-chain "ISRG Root X1"
自分はCronを使って定期更新させているので、cronコマンドを書き換える方法ではなく、以下の対応方法「confファイルにオプションを追加する」方法を取りました。
どっちでもいいんですが、個人的にはconfを設定する方が好きです。
対応方法2
「/etc/letsencrypt/renewal/」配下の「hogehoge.conf」に「preferred_chain」オプションを追加する。
〜中略~
# Options used in the renewal process
[renewalparams]
authenticator = apache
installer = apache
account = xxxxxxxxxxxxxxx
server = https://hogehoge.api.letsencrypt.org/directory
preferred_chain = ISRG Root X1 ←これを追加
保存できたら証明書の更新を「--dry-run」してみます。コマンドに「--preferred-chain」はつけません。
#dryrun
$ sudo certbot renew --dry-run --force-renewal
問題なくsuccessしたので実行します。
$ sudo certbot renew --force-renewal
Saving debug log to /var/log/letsencrypt/letsencrypt.log
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/hogehoge.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Plugins selected: Authenticator apache, Installer apache
Starting new HTTPS connection (1): hogehoge.api.letsencrypt.org
Renewing an existing certificate for hogehoge.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
new certificate deployed with reload of apache server; fullchain is
/etc/letsencrypt/live/hogehoge.com/fullchain.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
The following renewals succeeded:
/etc/letsencrypt/live/hogehoge.com/fullchain.pem (success)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
APIにアクセスしたら、ちゃんと動き出しました。
一件落着。
趣味のアプリとはいえ、お小遣い程度の売り上げに影響するので、早めに気づいてよかったです。
無料の外形監視でも入れておこうかな。
P.S.
コロナワクチン打った日だったので腕がちょー痛かったんですが、この作業している時は痛みのことを忘れてました。
集中した開発作業は、痛み止めにもなるんですね。