ユーザ用ツール

サイト用ツール


サーバ:ssl証明書_let_s_encrypt:自動更新に失敗

差分

このページの2つのバージョン間の差分を表示します。

この比較画面にリンクする

両方とも前のリビジョン 前のリビジョン
サーバ:ssl証明書_let_s_encrypt:自動更新に失敗 [2019/04/01 12:04]
yusuke_komori 削除
— (現在)
行 1: 行 1:
-====== SSL証明書の自動更新に失敗(Let's Encrypt) ====== 
-AWSのEC2同一サーバ内にて稼働させていたバーチャルドメイン3サイトの内、1サイトだけSSL証明書の更新に失敗していました。\\ 
-そこで、以下のコマンドにてログを確認。\\ 
-(オプション -l を付けることで、詳細なログが表示されます) 
-<code> 
-$ sudo systemctl status certbot-renew -l 
  
-● certbot-renew.service - This service automatically renews any certbot certificates found 
-   Loaded: loaded (/usr/lib/systemd/system/certbot-renew.service; static; vendor preset: disabled) 
-   Active: failed (Result: exit-code) since YYYY-mm-dd HH:ii:ss JST; 13h ago 
-  Process: 24164 ExecStart=/usr/bin/certbot renew $PRE_HOOK $POST_HOOK $RENEW_HOOK $CERTBOT_ARGS (code=exited, status=1/FAILURE) 
- Main PID: 24164 (code=exited, status=1/FAILURE) 
- 
- n月 dd 03:28:13 XXX.XXX.XXX.XXX certbot[24164]: All renewal attempts failed. The following certs could not be renewed: 
- n月 dd 03:28:13 XXX.XXX.XXX.XXX certbot[24164]: /etc/letsencrypt/live/example.com/fullchain.pem (failure) 
- n月 dd 03:28:13 XXX.XXX.XXX.XXX certbot[24164]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
- n月 dd 03:28:13 XXX.XXX.XXX.XXX certbot[24164]: Running post-hook command: apachectl graceful 
- n月 dd 03:28:13 XXX.XXX.XXX.XXX certbot[24164]: 1 renew failure(s), 0 parse failure(s) 
- n月 dd 03:28:13 XXX.XXX.XXX.XXX systemd[1]: certbot-renew.service: main process exited, code=exited, status=1/FAILURE 
- n月 dd 03:28:13 XXX.XXX.XXX.XXX systemd[1]: Failed to start This service automatically renews any certbot certificates found. 
- n月 dd 03:28:13 XXX.XXX.XXX.XXX systemd[1]: Unit certbot-renew.service entered failed state. 
- n月 dd 03:28:13 XXX.XXX.XXX.XXX systemd[1]: certbot-renew.service failed. 
-</code> 
-確かに example.com で更新に失敗しています。\\ 
-しかし、このログだけでは何が原因で失敗したのかわかりません。\\ 
-そこで、試しにSSL証明書の更新コマンドを実行してみます。 
-<code> 
-$ sudo certbot renew 
- 
-Saving debug log to /var/log/letsencrypt/letsencrypt.log 
- 
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
-Processing /etc/letsencrypt/renewal/example.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 example.com 
-Cleaning up challenges 
-Encountered exception during recovery: 
-Traceback (most recent call last): 
-  File "/usr/lib/python2.7/site-packages/certbot/error_handler.py", line 108, in _call_registered 
-    self.funcs[-1]() 
-  File "/usr/lib/python2.7/site-packages/certbot/auth_handler.py", line 310, in _cleanup_challenges 
-    self.auth.cleanup(achalls) 
-  File "/usr/lib/python2.7/site-packages/certbot/plugins/webroot.py", line 222, in cleanup 
-    os.remove(validation_path) 
-OSError: [Errno 2] No such file or directory: '/var/www/example.com/.well-known/acme-challenge/XXXXXXXXXX' 
-Attempting to renew cert (example.com) from /etc/letsencrypt/renewal/example.com.conf produced an unexpected error: 
-[Errno 2] No such file or directory: '/var/www/example.com'. Skipping. 
-</code> 
-すると、23行目で「ディレクトリが無いよ」というエラーが出ています。\\ 
-しかし、そもそも「/var/www/example.com/」というディレクトリ構成にしていないので、無くて当然です。\\ 
-ということは、証明書発行時のコマンドで、このサイトだけなにかミスっていたようです。 
- 
-3行目に「/var/log/letsencrypt/letsencrypt.log」にデバッグ情報を出力していると書かれていますが、今回は上記のように原因がわかったので、このログは置いておきます。 
- 
-Let's Encrypt について調べていたところ「/etc/letsencrypt/renewal」ディレクトリに、証明書更新のための設定ファイルがあることがわかったので、確認します。 
-<code> 
-$ sudo ls -l /etc/letsencrypt/renewal 
- 
-example.com.conf 
-example.net.conf 
-example.org.conf 
-</code> 
-こんな感じでサイト毎の設定ファイルがありました。\\ 
-次に、各設定ファイルの中身を確認します。\\ 
-<code> 
-# 更新に失敗していたドメイン 
-$ sudo less /etc/letsencrypt/renewal/example.com.conf 
- 
-# renew_before_expiry = 30 days 
-version = 0.27.1 
-archive_dir = /etc/letsencrypt/archive/example.com 
-cert = /etc/letsencrypt/live/example.com/cert.pem 
-privkey = /etc/letsencrypt/live/example.com/privkey.pem 
-chain = /etc/letsencrypt/live/example.com/chain.pem 
-fullchain = /etc/letsencrypt/live/example.com/fullchain.pem 
- 
-# Options used in the renewal process 
-[renewalparams] 
-authenticator = webroot 
-account = XXXXXXXXXXX 
-webroot_path = /var/www/example.com, 
-server = https://acme-v02.api.letsencrypt.org/directory 
-[[webroot_map]] 
-example.com = /var/www/example.com 
-</code> 
-<code> 
-# 更新に成功していたドメイン 
-$ sudo less /etc/letsencrypt/renewal/example.net.conf 
- 
-# renew_before_expiry = 30 days 
-version = 0.27.1 
-archive_dir = /etc/letsencrypt/archive/example.net 
-cert = /etc/letsencrypt/live/example.net/cert.pem 
-privkey = /etc/letsencrypt/live/example.net/privkey.pem 
-chain = /etc/letsencrypt/live/example.net/chain.pem 
-fullchain = /etc/letsencrypt/live/example.net/fullchain.pem 
- 
-# Options used in the renewal process 
-[renewalparams] 
-authenticator = apache 
-installer = apache 
-account = XXXXXXXXXXX 
-server = https://acme-v02.api.letsencrypt.org/directory 
-post_hook = apachectl graceful 
-</code> 
-上記を比較すると、失敗していたドメインと、成功していたドメインで設定に違いが出ています。\\ 
-やはり、証明書発行時に何かミスをしていたようです。\\ 
-そこで、成功していた設定ファイルを元に書き換えます。 
-<code> 
-$ sudoedit /etc/letsencrypt/renewal/example.com.conf 
- 
-# authenticator を webroot から apache に変更 
-authenticator = apache 
- 
-# installer を追加 
-installer = apache 
- 
-# 以下の webroot_path に関する行を削除 
-webroot_path = /var/www/example.com, 
- 
-# 以下の2行も削除 
-[[webroot_map]] 
-example.com = /var/www/example.com 
- 
-# 更新後に再起動するように以下を追加 
-post_hook = apachectl graceful 
-</code> 
-この状態で再度、証明証の更新を試します。 
-<code> 
-$ sudo certbot renew 
-</code> 
-今度は更新に成功しました。\\ 
-念の為、証明書の有効期限を確認します。 
-<code> 
-# 現在使用中の証明書ファイル名を確認 
-$ sudo ls -l /etc/letsencrypt/live/example.com/ 
- 
-README 
-cert.pem -> ../../archive/example.com/cert1.pem 
-chain.pem -> ../../archive/example.com/chain1.pem 
-fullchain.pem -> ../../archive/example.com/fullchain1.pem 
-privkey.pem -> ../../archive/example.com/privkey1.pem 
- 
-# 上記 cert.pem のシンボリックリンク先の証明書の有効期限を確認 
-$ sudo openssl x509 -noout -dates -in /etc/letsencrypt/archive/example.com/cert1.pem 
- 
-notBefore=Jan  n HH:ii:ss YYYY GMT 
-notAfter=Apr  n HH:ii:ss YYYY GMT 
-</code> 
-無事、有効期限が更新されていることを確認できました。 
サーバ/ssl証明書_let_s_encrypt/自動更新に失敗.1554087873.txt.gz · 最終更新: 2019/04/01 12:04 by yusuke_komori