概要
Let's encryptで作成したワイルドカード証明証の更新の備忘録
環境
- DNS
- AWS route53
- 証明書発行環境
- Ubuntu16.04
証明書の更新について
ワイルドカード証明書のため、 certbot renew
では更新ができない。
※注意※
完全にできないわけではなく、証明書作成時に発行される文字列をDNSの_acme-challengeのAliasのValueに値を設定しなければならないため、その文字列を変更するスクリプトを作成しておけば自動更新できるようになる。
更新作業
証明書の作成
前回の備忘録をもとに作成。(前提条件としてcertbotが入っていること)
作成される証明書は/etc/letsencrypt/live/
の下に作成される。
// 前回のものと同じ
$ sudo certbot certonly --manual -d '*.example.com' -m 'example@example.co.jp' --agree-tos --preferred-challenges dns-01 --server https://acme-v02.api.letsencrypt.org/directory
実行すると下記のように聞かれる
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
Cert is due for renewal, auto-renewing...
Renewing an existing certificate
Performing the following challenges:
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
yと返答すると
-------------------------------------------------------------------------------
(Y)es/(N)o: y
-------------------------------------------------------------------------------
Please deploy a DNS TXT record under the name
_acme-challenge.example.com with the following value:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Before continuing, verify the record is deployed.
-------------------------------------------------------------------------------
Press Enter to Continue
となるので、XXXのところの文字をDNSに設定する。
DNSが浸透するまで1分ほど待ち、Enterを押すと下記のようになり、発行完了。
Before continuing, verify the record is deployed.
-------------------------------------------------------------------------------
Press Enter to Continue
Waiting for verification...
Resetting dropped connection: acme-v02.api.letsencrypt.org
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-12-25. 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
DNSの設定
Route53 -> Hosted zones -> _acme-challenge
そのValueを変更して、「Save Record Set」を押下。
証明書のアップロード
EC2 -> ロードバランサー -> WebLoadBalancer -> リスナー
その443のSSL証明書の変更を押下し、設定する。(詳細は前回の備忘録を参考)
※注意※
やはり前回同様アップロードはできているが、設定はできなかった模様。(エラーになった)そのため、アップロード後にIAMを選ぶで設定しなおすことで更新ができた。