LoginSignup
4
6

More than 5 years have passed since last update.

Let's encrypt の更新が突然うまくいかなくなったのを解決した

Last updated at Posted at 2019-01-28

概要

WebサイトをSSL化するときに大変便利な Let's encrypt 。
私も、管理しているサイトで1年以上前(2017年)から利用しているのですが、今年(2019年)に入って、期限切れ予告メール1が届くようになりました。

...あれ?
更新用のコマンドをcronに入れて定期実行しているから、予告すら届かないはずなのに。
実際、2018年中は一度も期限切れ予告は来ていなかったのに...

ともかく、問題を解決しなければ証明書の期限切れが起きてしまうので、調査・対応しました。

解決方法

先に、解決方法を示しておきます。

  • rootユーザで実施しています。
  • ポイントは --webroot -w -d の3つのオプションです。
  • 残りのオプションはACME利用規約への同意と、期限切れ前でも実施できるようにするオプションです。
# ./certbot-auto certonly --webroot -w /var/www/html -d dummy.example.com -n --agree-tos --force-renewal

(中略)
Waiting for verification...
Cleaning up challenges

IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
  /etc/letsencrypt/live/dummy.example.com/fullchain.pem
(後略)

無事、更新に成功しました。
「--webroot」というオプションをつけることで、Let's encrypt内蔵のWebサーバではなく、ApacheやNginxなどのWebサーバのほうを見に行くようになります。

念のため、DRY-RUN(実際に更新はかけずに、チェックのみ実行する機能)を実施して、今後の更新にも問題が発生しないことを確認しておきましょう。

# ./certbot-auto renew --dry-run

(中略)
Congratulations, all renewals succeeded. The following certs have been renewed:
(後略)

問題なさそうです。めでたしめでたし。

何が起きていたか

次のようなエラーが発生していました。

# ./certbot-auto renew --dry-run

(中略)
Waiting for verification...
Cleaning up challenges
(ここから実際は赤文字で表示)
Attempting to renew cert (dummy.example.com) from /etc/letsencrypt/renewal/dummy
.example.com.conf produced an unexpected error:Unable to find a virtual host li
stening on port 80 which is currently needed for Certbot to prove to the CA that
 you control your domain. Please add a virtual host for port 80.. Skipping.
All renewal attempts failed. The following certs could not be renewed:
 /etc/letsencrypt/live/dummy.example.com/fullchain.pem (failure)
(赤文字こここまで、さらに中略)
1 renew failure(s), 0 parse failure(s)

「80番ポートでVirtualHostを立ててよ」というメッセージですが、実際にはApacheが稼働していて80番ポートをリッスンしていますし、ブラウザからアクセスしても問題なく80番ポートで応答がある状態です。
なので、最初は原因調査に難儀しました。。。

参考

https://qiita.com/HeRo/items/f9eb8d8a08d4d5b63ee9
https://free-ssl.jp/command/


  1. 「Let's Encrypt certificate expiration notice for domain "dummy.example.com"」というような件名のメールです。 

4
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
6