LoginSignup
6
1

More than 3 years have passed since last update.

LetsEncryptのワイルドカード証明書でハマった

Posted at

環境

・CentOS 7.4
・Nginx 1.12.2
・Certbot

証明書作成

certbotで以下コマンド実行。(manualオプションを使用)

certbot-auto certonly --manual \
--preferred-challenges dns-01 \
--server https://acme-v02.api.letsencrypt.org/directory \
-m xxx@xxxx.co.jp \
-d *.domain.com

実行すると質問形式になるので答えていく。
以下までくると、_acme-challengeをHostNameとしてValueをコピペしてドメイン管理しているサービスにTXTレコードとして登録しておく。

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please deploy a DNS TXT record under the name
_acme-challenge.domain.com with the following value:

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX(これをコピペ)

Before continuing, verify the record is deployed.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

登録後すぐにはDNSレコードが反映されないのでじっとここで我慢。digで↑で登録したValueになっているか確認。(この時は反映されるまで30分ほどかかった。)

dig txt _acme-challenge

反映されると次に進めていき完了。(反映される前に実行したりで何度かエラーになりました。)
成功すると以下に配置されるのでNginxのConf設定も以下に書き換える。

/etc/letsencrypt/live/domain.com-0001/fullchain.pem
/etc/letsencrypt/live/domain.com-0001/privkey.pem

自動更新でエラー

証明書を自動更新するために以下コマンドを定期処理にて実行。

certbot-auto renew --force-renewal

コマンドを手動で実行したところエラーになったのでconfig確認。

vi /etc/letsencrypt/renewal/domain.com-0001.conf 

確認すると、authenticatorが以下のようになっていた。

[renewalparams]
authenticator = manual

authenticatorをnginxに修正。念のためinstallerも追加。

[renewalparams]
authenticator = nginx
installer = nginx

再度コマンド実行すると正常に証明書が更新できました。

6
1
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
6
1