SSL証明書の更新(手動)する方法

更新の確認

証明書が更新(renew)できるかを確認します。更新できなければこのコマンドでエラーが出ます。途中で失敗して中途半端な更新になることを防げます。

certbot-auto renew --dry-run

更新

証明書を更新します。上記コマンドでエラーが出なければ基本的にはエラーなく更新することが出来ます。

certbot renew

更新でエラー

更新の確認でエラーが出ることがあります。私はこんなエラーが出ました。

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

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing *************************/early2home.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cert is due for renewal, auto-renewing...
Plugins selected: Authenticator webroot, Installer None
Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for early2home.com
Waiting for verification...
Cleaning up challenges
Attempting to renew cert (early2home.com) from *************************/early2home.com.conf produced an unexpected error: Failed authorization procedure. early2home.com (http-01): urn:ietf:params:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from *ttp://early2home.com/.well-known/acme-challenge/*************************: "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>404 Not Found</title>\n</head><body>\n<h1>Not Found</h1>\n<p". Skipping.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing *************************/www.early2home.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cert not yet due for renewal
All renewal attempts failed. The following certs could not be renewed:
*************************.pem (failure)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

The following certs are not due for renewal yet:
*************************.pem expires on 2020-09-17 (skipped)
All renewal attempts failed. The following certs could not be renewed:
*************************.pem (failure)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1 renew failure(s), 0 parse failure(s)

IMPORTANT NOTES:
- The following errors were reported by the server:

Domain: early2home.com
Type: unauthorized
Detail: Invalid response from
*ttp://early2home.com/.well-known/acme-challenge/*************************: "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML
2.0//EN\">\n<html><head>\n<title>404 Not
Found</title>\n</head><body>\n<h1>Not Found</h1>\n<p"

To fix these errors, please make sure that your domain name was
entered correctly and the DNS A/AAAA record(s) for that domain
contain(s) the right IP address.

このエラーの対処法として「証明書の設定」「SSL証明書が公開したがっている場所の公開」を実施します。

証明書の設定

vi *******************/early2home.com.conf

[[webroot_map]]
early2home.com = ********************
www.early2home.com = ********************

webroot_mapで設定した左辺はドキュメントルートの設定です。ドキュメントルートは、デフォルトでは次の場所に記載があります。

/etc/httpd/conf/httpd.conf

または、読み込み設定次第ですが、次のディレクトリ配下のconfファイルに記載があります。

/etc/httpd/conf.d/

SSL証明書が公開したがっている場所の公開

エラー出力の次の箇所を見て、同様のファイルを作成することで公開します。

Detail: Invalid response from
*ttp://early2home.com/.well-known/acme-challenge/*************************

公開する内容は何でもOKです、ブラウザで「http://early2home.com/.well-known/acme-challenge/*************************」にアクセスして、エラーにならなければ完了です。
対処が完了したら、再度 更新の確認を実施しましょう。上記のエラーが解消されているはずです。