Contents
SSL証明書を取得する (Let’s Encrypt)
最新のopen sslをインストールしておく
1.証明書のインストール
# certbot certonly –webroot -w /var/www/html/[ドメイン名] -d [ドメイン名]
# 受信可能なメールアドレスを指定
Enter email address (used for urgent notices and lost key recovery)
<管理者メールアドレス>
< OK > <Cancel>
# 利用条件に同意する
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf.
You must agree in order to register with the ACME server at
https://acme-v01.api.letsencrypt.org/directory
<Agree > <Cancel>
IMPORTANT NOTES:
– Congratulations! Your certificate and chain have been saved at
/etc/letsencrypt/live/[ドメイン名]/fullchain.pem. Your cert will
expire on 2022-01-27. To obtain a new version of the certificate in
the future, simply run Let’s Encrypt again.
– If you like Let’s Encrypt, please consider supporting our work by:
Donating to ISRG / Let’s Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le
# [Congratulations] と表示さえれば成功
# メッセージ中に記載の通り [/etc/letsencrypt/live/[ドメイン名]/] 配下に下記の証明書が取得されている
# cert.pem ⇒ SSLサーバー証明書(公開鍵含む)
# chain.pem ⇒ 中間証明書
# fullchain.pem ⇒ cert.pem と chain.pem が結合されたファイル
# privkey.pem ⇒ 公開鍵に対する秘密鍵
2.証明書を自動更新 (Let’s Encrypt)
①登録前のテスト
まず以下の–dry-runオプションを使って自動更新をテストしてみる。このオプションでは、証明書は更新されずに動作確認のみ実施されるため、証明書の取得回数制限に引っかかる心配もない
②crontab登録
# 毎月1日午前3時に、
# “root”ユーザが “/usr/bin/certbot renew”を実行
# “&&”で処理を連結
# WEBサーバー”apache”を再起動
00 03 01 * * root /usr/bin/certbot renew && /usr/sbin/service apache2 restart
Apache のhttps 化
念のため、下記をインストールしておく
1. ssl.conf ファイルの編集
●59 行目 コメント解除して変更
DocumentRoot “/var/www/html/<ドメイン名>”
●60 行目 コメント解除して変更
ServerName <ドメイン名>:443
●101行目 コメントにしてその下に追加
# SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateFile /etc/letsencrypt/live/<ドメイン名>/cert.pem
●109行目 コメントにしてその下に追加
# SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
SSLCertificateKeyFile /etc/letsencrypt/live/<ドメイン名>/privkey.pem
●119行目 追加
SSLCertificateChainFile /etc/letsencrypt/live/<ドメイン名>/chain.pem
success
# firewall-cmd –reload
success