勉強したことのメモ

Webエンジニア / プログラマが勉強したことのメモ。

Let's Encryptの自動更新時「Failed to renew certificate~」エラーの対応方法

CentOSからAlmaLinuxに移行後、初めてのLet's Encrypt更新日が来たんだけどCronによる自動更新が行われていないっぽい。そのため手動で「certbot renew」とコマンドを入力するとエラーが発生し更新できなかった。以下に対応方法をメモ。

 

エラー内容

サーバにSSH接続し「certbot renew」コマンドを入力すると以下エラーメッセージが表示された。

certbot renew

Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/test.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Failed to renew certificate test.com with error: The manual plugin is not working; there may be problems with your existing configuration.
The error was: PluginError('An authentication script must be provided with --manual-auth-hook when using the manual plugin non-interactively.',)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
All renewals failed. The following certificates could not be renewed:
  /etc/letsencrypt/live/test.com/fullchain.pem (failure)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1 renew failure(s), 0 parse failure(s)
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details.

翻訳すると以下内容になる。

証明書 test.com の更新に失敗しました。エラー: 手動プラグインが機能していません。既存の構成に問題がある可能性があります。
エラーは次のとおりでした: PluginError('手動プラグインを非対話的に使用する場合は、認証スクリプトに --manual-auth-hook を指定する必要があります。',)

 

対応方法

過去記事を参考に改めて証明書を作成することで解決した。具体的には以下コマンドを実行する(最初は--dry-runをつけてテストする方が安全)。

#証明書を作成(xxxxx.comは適宜変更する。また、テストしたい場合は後ろに--dry-runをつける)
certbot certonly --webroot -w /var/www/html/xxxxxxx -d xxxxx.com

問題無ければ以下コマンドでapacheを再起動する。

#apacheの再起動
systemctl restart httpd

 

所感

原因?

CentOSからAlmaLinuxに移行した際に、Let’s EncryptはHTTP認証ではなくDNS認証で導入したのが問題なのかも。もしくはその導入時に何らかの設定をミスしていたとか。と言うのもCentOSの頃は正常に自動更新できていたため。

次の更新時に正常に自動更新できているか要確認。

SSL証明書期限チェック

ちょっと前にサーバの死活監視としてAppmillというサイトに登録したんだけど、サーバの死活監視以外にもSSL証明書の有効期限とドメインの有効期限も監視してくれるのでオススメ。

今回のLet's Encryptの有効期限が迫っているのもこちらのサイトで気付けたので助かった。

 - サーバー

  関連記事

CentOS7系にLEMP環境(Linux + Nginx + MySQL + PHP)を構築

先日KAGOYAのVPSからIndigoに移行した際にCentOS6から7へバー ...

AlmaLinux8.6にLAMP環境&WordPressを構築する方法

だいぶ前にCentOS6系から7系に移行したが、7系も2024/6/30にサポー ...

Nginxのバーチャルホスト設定とLet's Encryptの導入

NginxでVirtualHostの設定し、複数のドメインを同一サーバに割り当て ...

OpenLiteSpeedにSSL証明書(Let's Encrypt)を導入しHTTPS接続する方法

昨日Almalinux8系に1-Click InstallでOpenLiteSp ...

CentOS6.10に無料SSL(Let's Encrypt)を導入

以前にもVPSにLet's Encryptを導入するという記事を書いたが、テスト ...