Fedora26でLet' Encrypt
Let's Encryptの証明書をFedora26で発行および自動更新の設定についてです.
あくまで私的メモです.
公式には2018年1月からワイルドカードが発行できるようになるとか書いてましたけど,今現在その兆候はないです....
1. Let's Encryptのインストール
[root@trompot ~]# dnf install letsencrypt
簡単ですね..
2. 証明書の発行
古い記事だとApacheを起動させたままだとエラーが...みたいなのを見つけましたが,今回は起動させておかないと発行できない方法です.
[root@trompot ~]# letsencrypt --text --renew-by-default --email trompot@example.com --domains www.example.com --agree-tos --webroot --webroot-path /var/www/html certonly
複数取得するときはドメインをカンマで区切るらしいです.
成功すると
Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator webroot, Installer None Obtaining a new certificate Performing the following challenges: http-01 challenge for example.com Using the webroot path /var/www/html for all unmatched domains. Waiting for verification... Cleaning up challenges IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/www.example.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/www.example.com/privkey.pem Your cert will expire on 2018-04-07. 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
となるので,後はApacheなどの設定で
/etc/letsencrypt/live/www.example.com/fullchain.pem
/etc/letsencrypt/live/www.example.com/privkey.pem
を設定に書き
[root@trompot~ ]# systemctl restart httpd
と再起動するとオッケーです
3. 自動更新させる
[root@trompot ~]# letsencrypt renew --post-hook "sudo service httpd restart"
コマンドで有効期限が近づいていれば更新を行い,それ以外はスルーするそうです.
これをSellScriptかなんかに書いてCronで月1回程度実行させてあげるといいでしょう.