ユーザ用ツール

サイト用ツール


サイドバー

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

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

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

$ 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.

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

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

$ sudo ls -l /etc/letsencrypt/renewal

example.com.conf
example.net.conf
example.org.conf

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

# 更新に失敗していたドメイン
$ 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
# 更新に成功していたドメイン
$ 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

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

$ 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

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

$ sudo certbot renew

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

# 現在使用中の証明書ファイル名を確認
$ 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

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

コメント

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