金曜日, 11月 10, 2017

Let's Encrypt証明書更新cron用サンプル

Let's Encryptのサーバ証明書の有効期限は3ヶ月なので、例えば
2月、5月、8月、11月の1日の01:00に更新する。
ポイントは、Let's Encrypt更新用コマンドを実行する前にhttpdを止めること。

(CentOS 6)
1 0 1 2,5,8,11 * root /sbin/service httpd stop > /dev/null 2>&1 && /usr/bin/certbot-auto certonly -n --standalone -d コモンネーム > /dev/null 2>&1;/sbin/service httpd start > /dev/null 2>&1

(CentOS 7)
1 0 1 2,5,8,11 * root /bin/systemctl stop httpd.service > /dev/null 2>&1 && /bin/certbot certonly -n --webroot -w /var/www/html -d コモンネーム > /dev/null 2>&1;/bin/systemctl start httpd.service > /dev/null 2>&1

(Ubuntu 16.04)
1 0 1 2,5,8,11 * root /bin/systemctl stop apache2.service > /dev/null 2>&1 && /usr/bin/letsencrypt certonly --standalone -d コモンネーム > /dev/null 2>&1;/bin/systemctl start apache2.service > /dev/null 2>&1

0 件のコメント: