twitter facebook

【SSL】Let's Encrypt でサブドメインのDNS認証

sub.hoge.com 用の SSL(Let's Encript)をDNS認証で取得する方法です。
IP制限, BASIC認証などかけているサイトなどに有用です。

①certbotコマンド

certbot certonly --manual -d sub.hoge.com --preferred-challenges dns
Please deploy a DNS TXT record under the name ... _acme-challenge.sub.hoge.com with the following value: 3SACbmTnYfJ7a7fycpB5PJlzK1-_Cr9j12345 ... Press Enter to Continue
Press Enter to Continue でまだ Enter をおさないこと!放置!!

②TXTレコードの設定

sub.hoge.com の場合、 _acme-challenge.sub.hoge.com に 上記で取得した値を TXTレコードに設定します。
_acme-challenge.sub.hoge.com. IN TXT "3SACbmTnYfJ7a7fycpB5PJlzK1-_Cr9j12345"
GUI画面の場合は以下の感じ
そして、なんとなく30分ぐらい待ちます(たぶん10分ぐらいでいいと・・・)
windows なら 以下を DOSプロンプトで対話形式でやると(linux なら dig ですね。)
> nslookup
> set type=TXT
> _acme-challenge.sub.hoge.com
以下のように値が帰ってくればそろそろ③に進む
_acme-challenge.sub.hoge.com text = "3SACbmTnYfJ7a7fycpB5PJlzK1-_Cr9j12345"

③ Enter を押します。

①で放置した状態の画面にたいし、Enter を押し処理を継続します。DNSにTXTレコードが反映される前にやるとエラーでやり直しになるので待っていました。
いい感じだと
Press Enter to Continue
Waiting for verification...
Cleaning up challenges

確認

ls /etc/letsencrypt/live/
あとは apacheなどの conf ファイルなどを変更!
APACHEでの参考
<VirtualHost *:443> ServerName sub.hoge.com DocumentRoot /var/www/html/sub.hoge.com SSLCertificateFile /etc/letsencrypt/live/sub.hoge.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/sub.hoge.com/privkey.pem Include /etc/letsencrypt/options-ssl-apache.conf </VirtualHost>
AUTHOR
@えのえの
最終更新日 2022/01/13
FAVORITE good stock
LINK TAG
記法を見る