なみひらブログ

学んだことを日々記録する。~ since 2012/06/24 ~

Let's Encryptの証明書更新でエラーがでて更新に失敗したのでその対応したときの作業メモ

背景

cronで証明書更新できているつもりが突然httpsでアクセスできなくなり、手動で更新コマンドを実行したらエラーがでました。
その対応したときの作業メモです。

問題事象

以下のコマンドを実行したらエラーメッセージがでました。

sudo certbot renew --no-self-upgrade

エラーメッセージ(一部修正と略)

http-01 challenge for www.example.com
Waiting for verification...
Cleaning up challenges
Attempting to renew cert (www.example.com) from /etc/letsencrypt/renewal/www.example.com.conf produced an unexpected error: Failed authorization procedure. www.example.com (http-01): urn:ietf:params:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://www.example.com/.well-known/acme-challenge/N9oxxxxxxxxxxxxxxxxxxxxxxxxxxI1UYUgFw0 [52.00.150.00]: 404. Skipping.
All renewal attempts failed. The following certs could not be renewed:
  /etc/letsencrypt/live/www.example.com/fullchain.pem (failure)

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

All renewal attempts failed. The following certs could not be renewed:
  /etc/letsencrypt/live/www.example.com/fullchain.pem (failure)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1 renew failure(s), 0 parse failure(s)

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

   Domain: www.example.com
   Type:   unauthorized
   Detail: Invalid response from
   http://www.example.com/.well-known/acme-challenge/N9oxxxxxxxxxxxxxxxxxxxxxxxxxxI1UYUgFw0
   [52.87.151.42]: 404

   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.

対応

証明書更新の手続きの際、Let's Encrypt側が今回の場合「http://www.example.com/.well-known/acme-challenge/N9oxxxxxxxxxxxxxxxxxxxxxxxxxxI1UYUgFw0」にアクセスして確認するため、外からこのファイルにアクセスできるようにする必要がある。
なので、空ファイルとして「/var/www/htlml/.well-known/acme-challenge/N9oxxxxxxxxxxxxxxxxxxxxxxxxxxI1UYUgFw0」を作る。そのあと、httpdでパスを通した。(httpd.conf)

# for App
<Location / >
  ProxyPass http://localhost:8080/
</Location>

# for cert
<Location /.well-known/ >
  ProxyPass !
</Location>

まとめ

導入時に正常にできていたのでスキップされていただけ?(´・ω・`)