Blog スタッフブログ

システム開発

[サーバー系]CertbotでのSSL

システム開発担当のTFです。

やり方

  • サーバーにCertbotをインストールする
  • certbot で Let’s Encrypt のSSL周りの設定ができる
  • cron で 毎月1日等に更新処理を叩くことで自動更新ができる
  • certbot delete –cert-name で選択して削除も可能

メモ

webサーバーの種類でコマンドが変わる( apache, nginx )

設定時にドメインを複数選択可能で、複数選択した場合、選択された全てでの証明書になる(1つでもドメイン確認できなくなれば落ちるので注意必要)

/etc/letsencrypt/
にできる

/etc/httpd/conf.d/vhost-le-ssl.conf
の鍵周りが自動で追記や書き換わったりする

certbot 叩く前に
/etc/httpd/conf.d/vhost.conf
の設定いる

certbot renew –dry-run
で実際に更新はせずにシミュレーション可能

サンプル

Certbotのインストール( コマンドはサーバーによる )

yum install -y mod_ssl
dnf list installed | grep mod_ssl
httpd -M | grep ssl

dnf install certbot python3-certbot-apache

Let’s Encryp のSSL周りの設定

certbot --apache
	# 対象のドメインの選択が出るので選択する
	# /etc/letsencrypt/ にSSL周りのファイルできる
	# /etc/httpd/conf.d/vhost-le-ssl.conf が書き換わる

cron設定

systemctl enable crond
systemctl start crond	

cron確認
crontab -l

cron設定
crontab -e
	分 時 日 月 曜日 certbot renew && systemctl restart httpd

削除の場合

certbot delete --cert-name 登録の名称(ドメインになるはず)

更新の動作確認

certbot renew --dry-run