参考にした記事
[引用記事]
certbot renew コマンドには、シミュレーション実行する –dry-run オプションがあります。 このオプションをつけておくと、実際には証明書の更新を行いません、 シミュレーションをするだけになります。 ですので、cron に設定するコマンドが定まるまでは、 この –dry-run オプションをつけながら検証することをおすすめします。 certbot renew --dry-run
certbot renewを手打ちしてみよう
[root@(マシン識別番号) ~]# certbot renew Saving debug log to /var/log/letsencrypt/letsencrypt.log - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Processing /etc/letsencrypt/renewal/(私有ドメイン).conf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Cert is due for renewal, auto-renewing... Plugins selected: Authenticator apache, Installer apache Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org Renewing an existing certificate Performing the following challenges: http-01 challenge for (私有ドメイン) Waiting for verification... Cleaning up challenges - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - new certificate deployed with reload of apache server; fullchain is /etc/letsencrypt/live/(私有ドメイン)/fullchain.pem - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations, all renewals succeeded. The following certs have been renewed: /etc/letsencrypt/live/(私有ドメイン)/fullchain.pem (success) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [root@(マシン識別番号) ~]#
解決
再発防止に備えて
Crondの起動を確認
# systemctl status crond * crond.service - Command Scheduler Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2020-03-23 10:09:26 JST; 5 months 1 days ago Main PID: 578 (crond) CGroup: /system.slice/crond.service `-578 /usr/sbin/crond -n Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
cronの実行履歴を確認してみよう
crontab -u root -e
00 05 * * * root certbot renew --force-renew
WEBサーバーも再起動させる Let’s Encrypt で発行したSSL/TLS証明書を Apache httpd や Nginx などのWEBサーバーに設定している場合が多いでしょう。 その場合、SSL/TLS証明書を更新したあとにWEBサーバーを再起動する必要があります。 この場合は、次のようにコマンドを設定するのが良いでしょう。
# Apache httpd を利用している場合の例 (CentOS 7 の場合) 00 04 01 * * certbot renew && systemctl restart httpd
原因の結論が出た。
SSL証明書の強制更新は毎日実行されていたが、
WebServer(Apache)の再起動処理をかけていなかったために、
更新されたものが反映されていなかったのだろう。
ログの確認
[root@(マシン名) (ドメイン名)]# cat /var/log/cron | grep certbot Aug 23 05:00:01 (マシン名) CROND[19282]: (一般ユーザー) CMD (certbot renew) Aug 23 05:00:01 (マシン名) CROND[19283]: (root) CMD (root certbot renew --force-renew) Aug 24 05:00:02 (マシン名) CROND[13099]: (一般ユーザー) CMD (certbot renew) Aug 24 05:00:02 (マシン名) CROND[13100]: (root) CMD (root certbot renew --force-renew)
[root@]# pwd /etc/letsencrypt/archive/(ドメイン名) [root@]# openssl x509 -noout -dates -in cert3.pem notBefore=Aug 24 00:19:37 2020 GMT notAfter=Nov 22 00:19:37 2020 GMT [root@]# ll total 48 -rw-r--r-- 1 root root 1907 May 12 13:25 cert1.pem -rw-r--r-- 1 root root 1903 May 13 13:54 cert2.pem -rw-r--r-- 1 root root 1907 Aug 24 10:19 cert3.pem -rw-r--r-- 1 root root 1647 May 12 13:25 chain1.pem -rw-r--r-- 1 root root 1647 May 13 13:54 chain2.pem -rw-r--r-- 1 root root 1647 Aug 24 10:19 chain3.pem -rw-r--r-- 1 root root 3554 May 12 13:25 fullchain1.pem -rw-r--r-- 1 root root 3550 May 13 13:54 fullchain2.pem -rw-r--r-- 1 root root 3554 Aug 24 10:19 fullchain3.pem -rw------- 1 root root 1704 May 12 13:25 privkey1.pem -rw------- 1 root root 1708 May 13 13:54 privkey2.pem -rw------- 1 root root 1704 Aug 24 10:19 privkey3.pem