LoginSignup
1
0

More than 3 years have passed since last update.

Let's Encrypt certbot renew 自動更新エラー

Last updated at Posted at 2020-02-06

Let's Encryptを使ってssl証明書を取得後、自動更新の設定をしたものの、エラーが出て自動更新されなかった時の解決法を一つ紹介します。

前提

・Debian(GCP)
・Let's Encryptを使ってSSL証明書の取得、https化が完了している。

目標

Let's EncryptのSSL証明書は有効期限が3ヶ月なのでnerewコマンドをcrontabで定期実行させて証明書を自動更新する。

変更前の設定(実行スケジュールの部分は省略)
crontab
certbot renew --post-hook "/etc/init.d/apache2 restart"
更新エラー

portが使用中なので更新できないと言っています。起動中のwebサーバ(SSL証明書の更新対象サービス)を停止させてからrenewコマンドを実行させなければいけませんでした。

WARNING:certbot.renewal:Attempting to renew cert from /etc/letsencrypt/renewal/SITE_URI.conf produced an unexpected error: At least one of the required ports is already taken.. Skipping.
変更後の設定(実行スケジュールの部分は省略)
crontab
certbot renew --pre-hook "/etc/init.d/apache2 stop" --post-hook "/etc/init.d/apache2 start"

変更前のコマンドに--pre-hookオプションを追加しました。

補足

・"/etc/init.d/apache2 restart"、"/etc/init.d/apache2 start"、"/etc/init.d/apache2 stop"の箇所はwebサーバの停止、起動、再起動のコマンドです。環境によって読み替えてください。

・rootユーザのcrontabに追加するとコマンドはroot権限で実行されます。他ユーザのcrontabに追加する時は"sudo /etc/init.d/apache2 restart"のようにコマンドの前にsudoを付ける必要があります。

・certbot renewの箇所は環境によってcertbot-autoなどに読み替えてください。環境によってcertbotのディレクトリを明示する場合もあります。/home/user_name/certbot renew など。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0