Let’s Encrypt の更新にまた失敗してたので原因を探る

技術記録

 前回修正したはずの問題にまた引っかかってしまったので、また問題を探ったところどうやらまた書き方が悪かったみたいなので更新する。自分用メモの覚え書きなのであまり信用しないように。

詳細は前回のものを見ていただいたあとならわかりやすいので要参照のこと。

tl; dr

 更新するcronのファイルの中の更新するコマンド行が書き間違えてました。

/root/certbot_renew.sh:

/bin/systemctl stop httpd

- /bin/certbot-auto renew
+ /usr/local/certbot/certbot-auto renew

/bin/systemctl start httpd

作業順序

 まずは前回の通りに更新してみる。

SHELL:

[***@*** ***]# certbot-auto -renew
/usr/bin/certbot-auto has insecure permissions!
To learn how to fix them, visit https://community.letsencrypt.org/t/certbot-auto-deployment-best-practices/91979/
Your system is not supported by certbot-auto anymore.
certbot-auto and its Certbot installation will no longer receive updates.
You will not receive any bug fixes including those fixing server compatibility
or security problems.
Please visit https://certbot.eff.org/ to check for other alternatives.
usage: 
  certbot-auto [SUBCOMMAND] [options] [-d DOMAIN] [-d DOMAIN] ...

Certbot can obtain and install HTTPS/TLS/SSL certificates.  By default,
it will attempt to use a webserver both for obtaining and installing the
certificate. 
certbot: error: unrecognized arguments: -renew

 …おっと?どうやらサポートを打ち切ったと書いてあるけど……。

 しかしながらそのままにしておくわけにもいかんので、参考文献の通りにまずは更新チェックをかけてみる

SHELL:

$ cd /usr/local/certbot

# 更新ができるかチェック
$ ./certbot-auto renew --dry-run
 ...>8cut...
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
** 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/*** (success)
  /etc/letsencrypt/live/*** (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.

 あれ?成功した…

 もしかしてと思ってまた前回のコードと見比べたんですが、たぶんカレントディレクトリがどうとかの初歩的な問題が解決してなかったっぽいので、–dry-runをけして本実行。

 できました。

 というわけで、つまるところ、手動更新したあと自動更新のcronファイルを修正しました。

/root/certbot_renew.sh:

/bin/systemctl stop httpd
/usr/local/certbot/certbot-auto renew
/bin/systemctl start httpd

 以上お役に立てれば幸いです。

参考文献

Let’s Encryptの更新エラーを解決した。: https://qiita.com/Lmachi/items/90e42046e57b16ee306f

タイトルとURLをコピーしました