無料で使用できるSSL証明書Let’sEncryptの有効期限を更新するコマンドと手順の記事になります。
無料で使用できるのですが、3ヶ月で有効期限がくるため更新が面倒ですが手順とコマンドを覚えれば簡単です。
環境は
OS:CentOS Linux 7
Webサーバ:nginx
- 現在のSSL有効期限の確認をする
- Webサーバnginxを停止する
- テスト更新をして可否の確認をする
- 更新コマンドを実行する
- Webサーバnginxを再起動する
- 更新後のSSL有効期限の確認をする
有効期限の確認コマンド
certbot certificates
残り期限のメッセージ
Found the following certs:
Certificate Name: example.com //更新対象のドメイン
Domains: example.com
Expiry Date: 2021-09-22 15:28:15+00:00 (VALID: 13 days)
Certificate Path: /etc/letsencrypt/live/example.com/fullchain.pem
Private Key Path: /etc/letsencrypt/live/example.com/privkey.pem
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
nginxを停止させる
systemctl stop nginx
certbot renew --dry-run
–dry-runを付けることで更新のテストができます。
Let’sEncryptは失敗するのに上限があり。1アカウント1ホストにつき1時間に5回までです。
** 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/example.com/fullchain.pem (success)
** DRY RUN: simulating ‘certbot renew’ close to cert expiry
** (The test certificates above have not been saved.)
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
更新に失敗した場合は赤字で問題点が表示されて、成功した場合は
と表示があります。
テストで更新できるのを確認した後、更新コマンドを実行です。
certbot renew
Congratulations, all renewals succeeded. The following certs have been renewed:
/etc/letsencrypt/live/example.com/fullchain.pem (success)
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
と表示を確認し、
nginxを再起動させる
systemctl restart nginx
最後に有効期限が延びていることを確認して終了です。
certbot certificates
Found the following certs:
Certificate Name: example.com //更新対象のドメイン
Domains: example.com
Expiry Date: 2021-12-08 12:00:55+00:00 (VALID: 89 days)
Certificate Path: /etc/letsencrypt/live/example.com/fullchain.pem
Private Key Path: /etc/letsencrypt/live/example.com/privkey.pem
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
コメント