開発したアプリなど一覧

Let's Encrypt でワイルドカード証明書を取得する

アフィリエイトリンクを含む場合があります

ある Web サービスで SSL 対応する際、サブドメインが多くなる事からワイルドカード証明書を取得する必要が出てきた。SSL には無料で利用可能な Let's Encrypt を使っているのだが、ワイルドカード証明書は通常のものと取得する手順が違うようなのでメモしておこう。

環境は Ubuntu 18.04, certbot 0.23.0 で行った。

まず certbot コマンドに引数 --manual と --preferred-challenges dns-01, --server https://acme-v02.api.letsencrypt.org/directory を指定する。コマンド全体は以下のような感じ。ドメインは example.com とする。

$ sudo certbot certonly --manual \ --preferred-challenges dns-01 \ --server https://acme-v02.api.letsencrypt.org/directory \ -m ryomatsu@example.com \ -d example.com \ -d *.example.com Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator manual, Installer None Obtaining a new certificate Performing the following challenges: dns-01 challenge for example.com dns-01 challenge for example.com

------------------------------------------------------------------------------- NOTE: The IP of this machine will be publicly logged as having requested this certificate. If you're running certbot in manual mode on a machine that is not your server, please ensure you're okay with that.

Are you OK with your IP being logged? ------------------------------------------------------------------------------- (Y)es/(N)o: y

IP アドレスがログに記録されるということなので Yes を選択して次へ進むと、以下のように DNS TXT レコードを登録しろと言われる。

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

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Before continuing, verify the record is deployed. ------------------------------------------------------------------------------- Press Enter to Continue

自分はムームードメインを利用しているので、管理画面にログインして対象のドメイン名の DNS 設定で以下のようにサブドメイン _acme-challenge, 種別に TXT, 内容に上記のコードを入力して保存する。

DNS が正常に反映されるまである程度時間がかかると思う。反映されるかどうか dig コマンドで確かめよう。

$ dig -t txt @dns01.muumuu-domain.com _acme-challenge.example.com

; <<>> DiG 9.11.3-1ubuntu1.5-Ubuntu <<>> -t txt @dns01.muumuu-domain.com _acme-challenge.example.com ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15974 ;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 1680 ;; QUESTION SECTION: ;_acme-challenge.example.com. IN TXT

;; ANSWER SECTION: _acme-challenge.example.com. 3600 IN TXT "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

;; Query time: 28 msec ;; SERVER: 202.239.23.40#53(202.239.23.40) ;; WHEN: Tue Oct 01 17:20:03 JST 2019 ;; MSG SIZE rcvd: 114

ANSWER SECTION で設定した値が表示されていればOK, ターミナルに戻って次へ進めよう。

Waiting for verification... Cleaning up challenges

IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/example.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/example.com/privkey.pem Your cert will expire on 2019-12-30. To obtain a new or tweaked version of this certificate in the future, simply run certbot again. To non-interactively renew *all* of your certificates, run "certbot renew" - If you like Certbot, please consider supporting our work by:

Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le

Congratulations! と表示されたら完了だ。あとは取得できた証明書を Apache なり Nginx で読み込ませよう。

Sponsored Link

コメント

タイトルとURLをコピーしました