mydns.jpの使用をやめてCloudFlareへ移行した。
certbot-dns-cloudflareというCertbot公式プラグインを使用することで、CloudFlare利用者は簡単に証明書の発行と更新が出来る。
ってことでやってみる。
OSはDebianStretchを使っている。
APT
# vi /etc/apt/source.list.d/backports.list deb http://ftp.debian.org/debian stretch-backports main # apt update # apt install -t stretch-backports certbot python3-certbot-dns-cloudflare
backportsについてはこちらを参考に
https://backports.debian.org/Instructions/
準備
certbot-dns-cloudflareはCloudFlareのAPIキーを必要とするので用意する。
CloudFlareのMy ProfileにAPI Keysという項目がある。
今回必要なのはGlobal API Keyなので、右側のViewをクリック、パスワードを入力したら取得できる。
以下の手順で資格情報を書いたファイルを作成する。
# mkdir /root/.cloudflare # chmod 700 /root/.cloudflare # vi /root/.cloudflare/credentials dns_cloudflare_email=CFで使っているEmail dns_cloudflare_api_key=Global APIキー # chmod 600 /root/.cloudflare/credentials
証明書の発行
certbot certonly \ --dns-cloudflare \ --dns-cloudflare-credentials /root/.cloudflare/credentials \ --dns-cloudflare-propagation-seconds 20 \ -d example.com \ -m root@example.com \ --agree-tos \ --manual-public-ip-logging-ok \ --dry-run
その他のオプションは適宜設定する。
実際に発行するには--dry-runを外すこと。
更新
certbot renew
renew時のオプションはこちらを参考に
コマンド解説 - Let's Encrypt 総合ポータル
-
- post-hookと--renew-hookの違いはこういう事らしいです。
cron
# crontab -e 0 4 * * * certbot renew -q --renew-hook "systemctl restart postfix" --renew-hook "systemctl restart dovecot"
終わり