Let’s Encrypt のルートドメインとワイルドカードドメインの証明書を取得してみた

検証環境を用意するのに HTTPS 通信が必須だったりすると、TLS 証明書も用意する必要があります。最近は、クラウド環境でクラウドベンダーが自動で用意してくれるマネージド証明書を使えるサービスが増えてきたので、自前で証明書を用意する事は少ないです。しかしながら、自前でドメインを所有しているなら、ルートドメインとワイルドカードドメインの証明書を用意しておけば、いろんな検証に利用できそうです。

M1 Mac に certbot をインストール

$ brew install certbot

$ certbot --version
certbot 3.0.1

certbot を使用してルートドメインとワイルドカードドメインの証明書を取得

$ sudo certbot certonly --manual \
  --preferred-challenges dns \
  --key-type rsa \
  -d "*.example.com" \
  -d "example.com" \
  -m "[email protected]" \
  --agree-tos

表示される TXT レコードを DNS に登録

自分が管理しているドメインの DNS サーバーに上記コマンドで表示される文字列を登録します。

別ターミナルで TXT レコードの登録状況を確認

$ dig @8.8.8.8 _acme-challenge.example.com txt

作成されたプライベートキーと証明書を確認

$ sudo ls -l /etc/letsencrypt/live/example.com/

(おまけ)pfx 形式に変換し作成されたファイルの情報を確認

$ sudo openssl pkcs12 -export \
  -inkey /etc/letsencrypt/live/example.com/privkey.pem \
  -in /etc/letsencrypt/live/example.com/fullchain.pem \
  -out example.pfx

$ openssl pkcs12 -info -in example.pfx

参考

https://letsencrypt.org/ja

https://certbot.eff.org

https://learn.microsoft.com/ja-jp/windows-hardware/drivers/install/personal-information-exchange—pfx–files

タグ: ,