ユーザ用ツール

サイト用ツール


サーバ:ssl証明書:自動更新に失敗_let_s_encrypt:上記以外で自動更新に失敗

【Let's Encrypt】ログを見ても自動更新に失敗した原因が分からない場合

ログだけでは何が原因で失敗したのかわからなかった場合は、試しにSSL証明書の更新コマンドを実行してみました。

  1. $ sudo certbot renew
  2.  
  3. Saving debug log to /var/log/letsencrypt/letsencrypt.log
  4.  
  5. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  6. Processing /etc/letsencrypt/renewal/example.com.conf
  7. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  8. Cert is due for renewal, auto-renewing...
  9. Plugins selected: Authenticator webroot, Installer None
  10. Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org
  11. Renewing an existing certificate
  12. Performing the following challenges:
  13. http-01 challenge for example.com
  14. Cleaning up challenges
  15. Encountered exception during recovery:
  16. Traceback (most recent call last):
  17. File "/usr/lib/python2.7/site-packages/certbot/error_handler.py", line 108, in _call_registered
  18. self.funcs[-1]()
  19. File "/usr/lib/python2.7/site-packages/certbot/auth_handler.py", line 310, in _cleanup_challenges
  20. self.auth.cleanup(achalls)
  21. File "/usr/lib/python2.7/site-packages/certbot/plugins/webroot.py", line 222, in cleanup
  22. os.remove(validation_path)
  23. OSError: [Errno 2] No such file or directory: '/var/www/example.com/.well-known/acme-challenge/XXXXXXXXXX'
  24. Attempting to renew cert (example.com) from /etc/letsencrypt/renewal/example.com.conf produced an unexpected error:
  25. [Errno 2] No such file or directory: '/var/www/example.com'. Skipping.

すると、23行目で「ディレクトリが無いよ」というエラーが出ています。
しかし、そもそも「/var/www/example.com/」というディレクトリ構成にしていないので、無くて当然です。
ということは、証明書発行時のコマンドで、なにかミスっていたようです。

「/etc/letsencrypt/renewal」ディレクトリに、証明書更新のための設定ファイルがあるので、確認します。

  1. $ sudo ls -l /etc/letsencrypt/renewal
  2.  
  3. example.com.conf
  4. example.net.conf
  5. example.org.conf

このようにサイト毎の設定ファイルがあります。
次に、各設定ファイルの中身を確認します。

  1. # 更新に失敗していたドメイン
  2. $ sudo less /etc/letsencrypt/renewal/example.com.conf
  3.  
  4. # renew_before_expiry = 30 days
  5. version = 0.27.1
  6. archive_dir = /etc/letsencrypt/archive/example.com
  7. cert = /etc/letsencrypt/live/example.com/cert.pem
  8. privkey = /etc/letsencrypt/live/example.com/privkey.pem
  9. chain = /etc/letsencrypt/live/example.com/chain.pem
  10. fullchain = /etc/letsencrypt/live/example.com/fullchain.pem
  11.  
  12. # Options used in the renewal process
  13. [renewalparams]
  14. authenticator = webroot
  15. account = XXXXXXXXXXX
  16. webroot_path = /var/www/example.com,
  17. server = https://acme-v02.api.letsencrypt.org/directory
  18. [[webroot_map]]
  19. example.com = /var/www/example.com
  1. # 更新に成功していたドメイン
  2. $ sudo less /etc/letsencrypt/renewal/example.net.conf
  3.  
  4. # renew_before_expiry = 30 days
  5. version = 0.27.1
  6. archive_dir = /etc/letsencrypt/archive/example.net
  7. cert = /etc/letsencrypt/live/example.net/cert.pem
  8. privkey = /etc/letsencrypt/live/example.net/privkey.pem
  9. chain = /etc/letsencrypt/live/example.net/chain.pem
  10. fullchain = /etc/letsencrypt/live/example.net/fullchain.pem
  11.  
  12. # Options used in the renewal process
  13. [renewalparams]
  14. authenticator = apache
  15. installer = apache
  16. account = XXXXXXXXXXX
  17. server = https://acme-v02.api.letsencrypt.org/directory
  18. post_hook = apachectl graceful

上記を比較すると、失敗していたドメインと、成功していたドメインで設定に違いが出ています。
証明書発行時に何かミスをしていたようです。
そこで、成功していた設定ファイルを元に書き換えます。

  1. $ sudoedit /etc/letsencrypt/renewal/example.com.conf
  2.  
  3. # authenticator を webroot から apache に変更
  4. authenticator = apache
  5.  
  6. # installer を追加
  7. installer = apache
  8.  
  9. # 以下の webroot_path に関する行を削除
  10. webroot_path = /var/www/example.com,
  11.  
  12. # 以下の2行も削除
  13. [[webroot_map]]
  14. example.com = /var/www/example.com
  15.  
  16. # 更新後に再起動するように以下を追加
  17. post_hook = apachectl graceful

この状態で再度、証明証の更新を試します。

  1. $ sudo certbot renew

今度は更新に成功しました。
念の為、証明書の有効期限を確認します。

  1. # 現在使用中の証明書ファイル名を確認
  2. $ sudo ls -l /etc/letsencrypt/live/example.com/
  3.  
  4. README
  5. cert.pem -> ../../archive/example.com/cert1.pem
  6. chain.pem -> ../../archive/example.com/chain1.pem
  7. fullchain.pem -> ../../archive/example.com/fullchain1.pem
  8. privkey.pem -> ../../archive/example.com/privkey1.pem
  9.  
  10. # 上記 cert.pem のシンボリックリンク先の証明書の有効期限を確認
  11. $ sudo openssl x509 -noout -dates -in /etc/letsencrypt/archive/example.com/cert1.pem
  12.  
  13. notBefore=Jan n HH:ii:ss YYYY GMT
  14. notAfter=Apr n HH:ii:ss YYYY GMT

無事、有効期限が更新されていることを確認できました。

コメント

コメントを入力. Wiki文法が有効です:
 
サーバ/ssl証明書/自動更新に失敗_let_s_encrypt/上記以外で自動更新に失敗.txt · 最終更新: 2020/11/05 11:22 by humolife