Certbot による無料の Let's Encrypt 証明書の更新が成功したことを確認する方法

Certbot による無料の Let's Encrypt 証明書の更新が成功するかどうかを確認する方法は、次の 2 つの質問に分類できます。 1. スケジュールされたタスクが存在するかどうかを確認します。 2. 更新操作が成功するかどうかを確認する

スケジュールされたタスクが存在するかどうかを確認する

1
2
3
4
5
6
7
8
root@localhost:~# sudo systemctl status certbot.timer
 certbot.timer - Run certbot twice daily
     Loaded: loaded (/lib/systemd/system/certbot.timer; enabled; vendor preset: enabled)
     Active: active (waiting) since Wed 2022-12-07 02:08:51 UTC; 22h ago
    Trigger: Thu 2022-12-08 04:56:59 UTC; 3h 49min left
   Triggers:  certbot.service

Dec 07 02:08:51 localhost systemd[1]: Started Run certbot twice daily.

上記のスケジュールされたタスクが存在する場合、タイミングは成功です。
新しいバージョンでは、スケジュールされたタスクはインストール中に自動的に設定されるため、手動で設定する必要はありません。

更新操作が成功するかどうかを確認する

certbot renew コマンドを使用して確認します。実行後、certbot が管理するすべてのドメイン名が検証されます。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
root@localhost:~# sudo certbot renew --dry-run
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/abc.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Simulating renewal of an existing certificate for ijoke.fun and abc.com and www.abc.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/knightli.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Simulating renewal of an existing certificate for knightli.com and www.knightli.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations, all simulated renewals succeeded: 
  /etc/letsencrypt/live/abc.com/fullchain.pem (success)
  /etc/letsencrypt/live/knightli.com/fullchain.pem (success)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

すべてのシミュレートされた更新が成功したことを確認し、すべてが成功したことを示します。

よくある失敗例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
root@localhost:/# sudo certbot renew --dry-run
Saving debug log to /var/log/letsencrypt/letsencrypt.log
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/abc.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Simulating renewal of an existing certificate for abc.com and www.abc.com
Failed to renew certificate abc.com with error: Could not bind TCP port 80 becau
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/knightli.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Simulating renewal of an existing certificate for knightli.com and www.knightli.com
Failed to renew certificate knightli.com with error: Could not bind TCP port 80 because it is already in use by another process on this system (such as a web server). Please stop the program in question and then try again.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
All simulated renewals failed. The following certificates could not be renewed:
  /etc/letsencrypt/live/abc.com/fullchain.pem (failure)
  /etc/letsencrypt/live/knightli.com/fullchain.pem (failure)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2 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.

上記は失敗例です。失敗の理由は、証明書の申請時にスタンドアロン方式が使用されたためです。 Certbotは申請時および更新時に自らhttpサービスを構築します。これが他の http サーバーを実行しているサーバーである場合、障害が発生します。

これを成功させるには、certbot の構成ファイルを変更する必要があります。

/etc/letsencrypt/renewal/ ディレクトリでドメイン名に対応する構成ファイルを見つけます。

1
2
3
4
5
root@localhost:~# ll /etc/letsencrypt/renewal
drwxr-xr-x 2 root root 4096 Dec  7 02:59 ./
drwxr-xr-x 9 root root 4096 Dec  8 01:09 ../
-rw-r--r-- 1 root root  530 Dec  7 02:59 abc.com.conf
-rw-r--r-- 1 root root  545 Dec  7 02:59 knightli.com.conf

対応する構成ファイルを変更します

1
2
3
4
5
6
原有
authenticator = standalone

修改成(适用于nginx服务器的情形)
authenticator = nginx
installer = nginx
记录并分享
Hugo で構築されています。
テーマ StackJimmy によって設計されています。