はじめに
Let’s EncryptでDNS認証を用いてワイルドカード証明書を発行します。
発行に使ったOSはCentOS7( CentOS Linux release 7.4.1708 (Core) )です。
certbotのインストール
公式にあるとおり、yumコマンドで簡単にインストールできます。
[user@websv1 ~]$ sudo yum install epel-release [user@websv1 ~]$ sudo yum install certbot
証明書発行
開始する前に、以下を準備してください。
・メールアドレス(有効期限が近付いた際に通知が来ます)
・DNSの管理アクセス権(当たり前ですが、DNSにレコード登録できないとこの手順は実行できません)
以下のコマンドを打ちます。
メールアドレスとドメインは正しいものに書き換えて実行してください。
[user@websv1 ~]$ sudo certbot certonly \ --manual \ --server https://acme-v02.api.letsencrypt.org/directory \ --email example@example.com \ --agree-tos \ --manual-public-ip-logging-ok \ --preferred-challenges dns \ --domain *.example.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator manual, Installer None Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org Obtaining a new certificate Performing the following challenges: dns-01 challenge for example.com ------------------------------------------------------------------------------- Please deploy a DNS TXT record under the name _acme-challenge.example.com with the following value: sQYXginymMXXXXXXXXXXXXXg8RFjTQ Before continuing, verify the record is deployed. ------------------------------------------------------------------------------- Press Enter to Continue
ここで、Enterを押す前に指定されたレコードをDNSに登録します。
この例では[_acme-challenge]というTXTレコードを[example.com]に作ってください。
レコードに指定された「sQYXginy….」という値を登録します。
反映に時間がかかるかもしれないので、少し待ってからEnterを押してください。
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 2018-07-20. 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
/etc/letsencrypt/live/example.com/ に作成された証明書と秘密鍵があります。
おまけ)p12形式への変換
WindowsやIISで使うために、p12形式に変更します。
・opensslが入っていなければyumでインストールしてください。
・/etc/letsencrypt/live/example.com/ への読み書き権限のあるユーザで作業してください。
[user@websv1 ~]$ cd /etc/letsencrypt/live/example.com/ [user@websv1 example.com] openssl pkcs12 -export -out certfile.p12 -in cert.pem -inkey privkey.pem Enter Export Password: (任意のパスワードを入力) Verifying - Enter Export Password: (再度上記と同じパスワードを入力)
これで、/etc/letsencrypt/live/example.com/にcertfile.p12ができました。