Let’s Encrypetインストール&使い方
尚、登場する暗号化情報やexample.jpドメイン名及びメールアドレスadmin@example.jpはフィクションです
1.インストール
$ pkg install py38-certbot
portsだと
$ cd /usr/ports/security/py-certbot && make install clean
■コマンド
$ /usr/local/bin/certbot
2.新規証明書取得
$ certbot certonly --standalone -d www.example.jp --agree-tos -m admin@example.jp
3.時期が来たら証明書更新(自分のサーバーの場合)
$ certbot renew
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Processing /usr/local/etc/letsencrypt/renewal/www.example.jp.conf
Renewing an existing certificate for www.example.jp
Congratulations, all renewals succeeded: /usr/local/etc/letsencrypt/live/www.example.jp/fullchain.pem (success)
■うまく行ったかログをみてみる
$ cat /var/log/letsencrypt/letsencrypt.log
■今度はいつが更新時期か見る
$ certbot certificates
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Found the following certs: Certificate Name: www.example.jp Serial Number: 3e8e33e06b902c201f057fb49edbfb104c7 Key Type: RSA Domains: www.example.jp
Expiry Date: 2024-07-25 22:28:40+00:00 (VALID: 89 days)
Certificate Path: /usr/local/etc/letsencrypt/live/www.example.jp/fullchain.pem
Private Key Path: /usr/local/etc/letsencrypt/live/www.example.jp/privkey.pem
ここでは、次回更新が
Expiry Date: 2024-07-25 22:28:40
となる。
4.自動更新の設定(これ今回初めてやってみる)
■パッケージには更新スクリプトが付属している
$ ls -al /usr/local/etc/periodic/weekly/500.certbot-3.9
-r-xr-xr-x 1 root wheel 2494 Apr 16 11:33 /usr/local/etc/periodic/weekly/500.certbot-3.9
■更新スクリプトを有効にする場合はこうする
$ vi /etc/defaults/periodic.conf
以下追加
weekly_certbot_enable="YES" #500.certbot
■証明書のあるディレクトリは以下です
$ sudo ls -al /usr/local/etc/letsencrypt/live/
total 32
drwx------ 3 root wheel 512 Aug 5 2022 .
drwxr-xr-x 9 root wheel 512 Apr 27 08:56 ..
-rw-r--r-- 1 root wheel 740 Aug 5 2022 README
drwxr-xr-x 2 root wheel 512 Apr 27 08:28 www.example.jp