ユーザ用ツール

サイト用ツール


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

差分

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

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

次のリビジョン
前のリビジョン
サーバ:ssl証明書:自動更新に失敗_let_s_encrypt [2019/04/01 12:04]
yusuke_komori 作成
サーバ:ssl証明書:自動更新に失敗_let_s_encrypt [2020/11/05 12:03] (現在)
humolife [自動更新失敗の原因]
行 1: 行 1:
 ====== SSL証明書の自動更新に失敗(Let's Encrypt) ====== ====== SSL証明書の自動更新に失敗(Let's Encrypt) ======
-AWSのEC2同一サーバ内て稼働させていバーチャルドメイン3サイトの内、1サイトだけSSL証明書の更新に失敗していました\\ +自動更新失敗し場合、以下のようなタイトメールが届きます。 
-そこで、以下のコマンドてログを確認。\\+> Let's Encrypt certificate expiration notice for domain "example.com" 
 +実際にサイトにアクセスして証明書の有効期限を確認すると、30日を切っいることが確認できるかと思いま。 
 +そこで、サーバアクセスし、certbot-renew のステータスを確認します。\\
 (オプション -l を付けることで、詳細なログが表示されます) (オプション -l を付けることで、詳細なログが表示されます)
 <code> <code>
-sudo systemctl status certbot-renew -l+sudo systemctl status -l certbot-renew
  
 ● certbot-renew.service - This service automatically renews any certbot certificates found ● certbot-renew.service - This service automatically renews any certbot certificates found
行 21: 行 23:
  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]: Unit certbot-renew.service entered failed state.
  n月 dd 03:28:13 XXX.XXX.XXX.XXX systemd[1]: certbot-renew.service failed.  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 +# より詳細なログを見たい場合は、以下のファイルを確認します 
- +sudo less /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> </code>
-すると、23行目で「ディレクトリが無いよ」というエラーが出ています。\\ 
-しかし、そもそも「/var/www/example.com/」というディレクトリ構成にしていないので、無くて当然です。\\ 
-ということは、証明書発行時のコマンドで、このサイトだけなにかミスっていたようです。 
  
-3行目に「/var/log/letsencrypt/letsencrypt.log」にデバッグ情報を出力していると書かれていますが、今回は上記ように原因がわかったので、このログは置いておきます。 +===== 自動更新失敗の原因 ===== 
- +  - [[サーバ:ssl証明書:自動更新に失敗_let_s_encrypt:Basic認証で弾かれ|Basic弾かれる]
-Let's Encrypt について調べていたところ「/etc/letsencrypt/renewal」ディレクトリに、証明書更新のための設定ファイルがあことがわかったので、確します。 +  - [[サーバ:ssl証明書:自動更新に失敗_let_s_encrypt:キュメントルートの問題|キュメンート問題]] 
-<code> +  [[サーバ:ssl証明書:自動更新に失敗_let_s_encrypt:上記自動更新に失敗|上記以外で自動更新に失敗]]
-$ 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.1554087876.txt.gz · 最終更新: 2019/04/01 12:04 by yusuke_komori