ユーザ用ツール

サイト用ツール


let_encrypt

Let's Encrypt

概要

Let's EncryptはSSL証明書を発行するサービスであり、これを利用することで、個人でも有効なSSL証明書を得ることができる。

ワイルドカード証明書の取得

従来、Let's Encryptに於いては、サブドメインの証明書を得るには、certbot に -d でサブドメインを列挙して証明書を得るしかなかったが、現在ではワイルドカードによる認証が得られるようになっているので、いくつものサービスをサブドメイン名で切り分けて提供している場合に、一々、証明書を取り直さなくて良くなっている。

ただし、certbot のプラグインが提供されていないDNSサービスの場合には、証明書の更新を certbot renew では行うことができなくなるので注意が必要である。

ここでは、対応していないケースでの証明書の取得と更新について説明する。 とりあえず、certbot certonly を起動するのだが、このとき –manual をつける。 プラグインがある場合は、それとそれ用のオプションも渡すことになるが、それはここでは触れない。

途中で、「DNSに_acme-challenge.<ドメイン名> でTXTレコードにこの値を登録しろ」といって止まるので、いわれた値をDNSに登録する。要は、この作業が自動化できるプラグインがなければ、renewもできないから、手動で都度やってやる必要があるのだ。

root@example.com:~# certbot certonly --manual --preferred-challenges dns-01 -m webmaster@example.com -d example.com -d '*.example.com' -v
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator manual, Installer None
Certificate is due for renewal, auto-renewing...
Renewing an existing certificate for example.com and *.example.com
Performing the following challenges:
dns-01 challenge for example.com
dns-01 challenge for example.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please deploy a DNS TXT record under the name:

_acme-challenge.example.com.

with the following value:

xXXxXXX0xxXxXX0XxXxXxXxX0xxxx0x0xXXx0x0XXXx

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Press Enter to Continue

ここでは、ドメイン exmaple.com に、ワイルドカードで *.example.com の証明書を取得する例でやっているが、上のように、「以下の値を登録しろ」といわれるので、いわれた値をDNSのTXTレコードに登録する。

登録が終わって、DNSを引いて、この値が実際に表示されることを確認する。

root@example.com:~# dig txt _acme-challenge.example.com

; <<>> DiG 9.18.1-1ubuntu1.2-Ubuntu <<>> txt _acme-challenge.example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48959
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

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

;; ANSWER SECTION:
_acme-challenge.example.com. 86400 IN   TXT     "xXXxXXX0xxXxXX0XxXxXxXxX0xxxx0x0xXXx0x0XXXx"

;; Query time: 4 msec
;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP)
;; WHEN: Thu Nov 17 15:48:30 JST 2022
;; MSG SIZE  rcvd: 168

root@example.com:~# 

登録できていたら、何か、キーを押して処理を進める。 理由はよくわからないが、もう一つキーを提示されて、登録しろといわれる。 このとき、書かれているように、先に登録した値を削除してはいけないらしい。 DNSは同じTXTレコードを複数持ってもいいから、構わずやれというのでやる。

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please deploy a DNS TXT record under the name:

_acme-challenge.example.com.

with the following value:

yYY-yYyy9Y9yyy_YyYyYYy9y9yy_yyyYyY999yYYyYY

(This must be set up in addition to the previous challenges; do not remove,
replace, or undo the previous challenge tasks yet. Note that you might be
asked to create multiple distinct TXT records with the same name. This is
permitted by DNS standards.)

Before continuing, verify the TXT record has been deployed. Depending on the DNS
provider, this may take some time, from a few seconds to multiple minutes. You can
check if it has finished deploying with aid of online tools, such as the Google
Admin Toolbox: https://toolbox.googleapps.com/apps/dig/#TXT/_acme-challenge.wildtree.jp.
Look for one or more bolded line(s) below the line ';ANSWER'. It should show the
value(s) you've just added.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Press Enter to Continue
Waiting for verification...
Cleaning up challenges

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/example.com/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/example.com/privkey.pem
This certificate expires on 2023-02-15.
These files will be updated when the certificate renews.

NEXT STEPS:
- This certificate will not be renewed automatically. Autorenewal of --manual certificates requires the use of an authentication hook script (--manual-auth-hook) but one was not provided. To renew this certificate, repeat this same certbot command before the certificate's expiry date.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
root@example.com:~# 

両方のTXTレコードが存在していることを確認したら、キーを押して処理を終える。 最後にいわれているように、誰もプラグインを作ってくれてないから、更新のときも同じことをやれといわれる。 有効期限は90日だが、残り30日を切るとお知らせのメールが来るからその時上と同じ作業を行う。

ワイルドカード証明書の更新

更新に関しては、登録時にいわれたように、登録と全く同じ作業を行う。

let_encrypt.txt · 最終更新: 2022/11/17 17:03 by araki