(31) Webサイトに無償SSL証明書を導入
Let's EncryptはSSL(TLS)に利用できるサーバ証明書を無償で発行しているサービスです。
証明書の発行期限は90日と短いですが、無料で導入できます。
証明書の発行期限が90日と短いですが、証明書発行コマンドをcronに設定すれば自動でもおこなえます
・CentOS7 に Let's Encryptをインストール
インストールする場所に移動して、githubからcertbotのレポジトリをcloneします。
# cd /usr/local
# git clone https://github.com/certbot/certbot
・Let's Encrypt クライアントが依存するパッケージをインストールします
# cd certbot
# ./certbot-auto
下記のコマンドで証明書を取得します。使用する環境にあわせてディレクトリ、ドメイン名、メールアドレスは変更します。
# ./certbot-auto certonly --webroot -w /data/html -d www.totsusangyo.com -m hogehoge@totsusangyo.com --agree-tos
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at
/etc/letsencrypt/live/www.totsusangyo.com/fullchain.pem. Your cert
will expire on 2017-02-15. To obtain a new or tweaked version of
this certificate in the future, simply run certbot-auto again. To
non-interactively renew *all* of your certificates, run
"certbot-auto 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
・証明書や秘密鍵などは「/etc/letsencrypt/archive/」以下に保存されます。
下記の場所にシンボリックリンクが生成されます。
証明書: /etc/letsencrypt/live/www.totsusangyo.com/cert.pem
証明書+中間CA証明書: /etc/letsencrypt/live/www.totsusangyo.com/fullchain.pem
秘密鍵: /etc/letsencrypt/live/www.totsusangyo.com/privkey.pem
中間CA証明書: /etc/letsencrypt/live/www.totsusangyo.com/chain.pem
・設定変更後は、Apacheを再起動します
# systemctl reload httpd
SSLの更新は以下のコマンドをcronに設定して、毎月1日の朝6時に証明書を自動更新して、Apacheをリロードします。
# crontab -e
00 06 01 * * /usr/local/certbot/certbot-auto renew --force-renew && /bin/systemctl reload httpd