Let’s Encrypt を使う

Tech

Let’s Encrypt で証明書を入手した。手順等を諸々。

まず、ACME という仕組みでサーバとやり取りして証明書を入手する(らしい)ので、その準備。certbot が特定のディレクトリにファイルを格納して、サーバ側はそのファイルを取得する。OK なら certbot に証明書を送ってくるので、それを保存する、というのが流れ(らしい)。

複数のドメインを格納するので、Let’s Encrypt 用の設定ファイルをつくっておく。

root で指定しているのがサーバがアクセスしてくるパス。
サイトの設定ファイル(sites-avalable の中のファイル)も編集。

letsencrypt.conf を include している。他のドメインも同様に設定してやって、

$ sudo apt install certbot
$ sudo certbot certonly --webroot -w /path/to/letsencrypt -d develop.hoge.com -d fuga.com -d www.fuga.com

これで証明書が取得される。以下のような出力があるはず。

IMPORTANT NOTES:
– Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/develop.hoge.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/develop.hoge.com/privkey.pem
Your cert will expire on 2018-08-19. 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”
– Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.
– 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

https の設定は、サイトの設定ファイルに。

必要そうな部分はこんなものでしょうか。TLS を受け付けないようにしている(つもり)。

あとは crontab で自動で更新させる。週 1 回確認。root の crontab に書いた(つもり)。

ちなみに sudo /usr/bin/certbot renew --dry-run で更新はせずに動作チェックできる。

参考:コマンド解説

コメント

タイトルとURLをコピーしました