【CentOS7】Let's Encryptの証明書を自動更新させる | 瀬戸内の雲のように

【CentOS7】Let's Encryptの証明書を自動更新させる

Posted: 2018-03-26


スポンサーリンク

目次

背景

こちらの記事でも書いておりますが、当ブログはLet's Encryptを使ってSSL化しております。

このLet's Encryptは無料でSSL証明書を発行してくれるので大変ありがたいのですが、期間が3ヶ月しかないため、油断するとすぐに期限切れしてしまいます。

今回はそんなお悩みを解決するため、証明書を自動更新する設定をメモしておきます。

環境

  • CentOS Linux release 7.4.1708 (Core)
  • certbot 0.19.0

cronの設定

# echo '0 0 * * * /usr/bin/certbot renew --post-hook "/usr/bin/systemctl restart nginx.service" > /dev/null 2>&1'

(前提)普通に手作業で更新する場合の手順

インストール時に使ったcertbotコマンドで更新できます。

コマンド

 /usr/bin/certbot renew --post-hook "/usr/bin/systemctl restart nginx.service"

成功した時の実行結果

/log/letsencrypt/letsencrypt.log

-------------------------------------------------------------------------------
Processing /etc/letsencrypt/renewal/blog.setouchino.cloud.conf
-------------------------------------------------------------------------------
Cert is due for renewal, auto-renewing...
Plugins selected: Authenticator webroot, Installer None
Starting new HTTPS connection (1): acme-v01.api.letsencrypt.org
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for blog.setouchino.cloud
Waiting for verification...
Cleaning up challenges

-------------------------------------------------------------------------------
new certificate deployed without reload, fullchain is
/etc/letsencrypt/live/blog.setouchino.cloud/fullchain.pem
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
Processing /etc/letsencrypt/renewal/www.setouchino.cloud.conf
-------------------------------------------------------------------------------
Cert is due for renewal, auto-renewing...
Plugins selected: Authenticator webroot, Installer None
Starting new HTTPS connection (1): acme-v01.api.letsencrypt.org
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for www.setouchino.cloud
Waiting for verification...
Cleaning up challenges

-------------------------------------------------------------------------------
new certificate deployed without reload, fullchain is
/etc/letsencrypt/live/www.setouchino.cloud/fullchain.pem
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
Processing /etc/letsencrypt/renewal/setouchino.cloud.conf
-------------------------------------------------------------------------------
Cert is due for renewal, auto-renewing...
Plugins selected: Authenticator webroot, Installer None
Starting new HTTPS connection (1): acme-v01.api.letsencrypt.org
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for setouchino.cloud
Waiting for verification...
Cleaning up challenges

-------------------------------------------------------------------------------
new certificate deployed without reload, fullchain is
/etc/letsencrypt/live/setouchino.cloud/fullchain.pem
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------

Congratulations, all renewals succeeded. The following certs have been renewed:
  /etc/letsencrypt/live/blog.setouchino.cloud/fullchain.pem (success)
  /etc/letsencrypt/live/www.setouchino.cloud/fullchain.pem (success)
  /etc/letsencrypt/live/setouchino.cloud/fullchain.pem (success)
-------------------------------------------------------------------------------

 
 
ちなみにこのcertbotコマンドで更新する際、期限が残っている等の理由で更新不要の場合にはスキップします。

更新が不要な時の実行結果

# /usr/bin/certbot renew --post-hook "/usr/bin/systemctl restart nginx.service"
Saving debug log to /var/log/letsencrypt/letsencrypt.log

-------------------------------------------------------------------------------
Processing /etc/letsencrypt/renewal/blog.setouchino.cloud.conf
-------------------------------------------------------------------------------
Cert not yet due for renewal

-------------------------------------------------------------------------------
Processing /etc/letsencrypt/renewal/www.setouchino.cloud.conf
-------------------------------------------------------------------------------
Cert not yet due for renewal

-------------------------------------------------------------------------------
Processing /etc/letsencrypt/renewal/setouchino.cloud.conf
-------------------------------------------------------------------------------
Cert not yet due for renewal

-------------------------------------------------------------------------------

The following certs are not due for renewal yet:
  /etc/letsencrypt/live/blog.setouchino.cloud/fullchain.pem (skipped)
  /etc/letsencrypt/live/www.setouchino.cloud/fullchain.pem (skipped)
  /etc/letsencrypt/live/setouchino.cloud/fullchain.pem (skipped)
No renewals were attempted.
No hooks were run.
-------------------------------------------------------------------------------

このため、このコマンドをcron設定しておけば必要な時だけ自動で更新してくれます。

自動更新の設定

crontabに以下のコマンドを追記します。

0 0 * * * /usr/bin/certbot renew --post-hook "/usr/bin/systemctl restart nginx.service" > /dev/null 2>&1

これで毎日0:00に更新を試みてくれます。

crontab -eか ファイルに出力した上でcrontab "ファイル名" で追記できます。

以上です。


スポンサーリンク




コメント一覧

2022/05/20 21:43:25

koliezbrさん

buy modafinil pills order provigil online cheap cost provigil


2022/05/21 01:00:27

Nndenplugsさん

levitra 10 mg schmelztabletten levitra orosolubile costo https://xclevitradb.com/


2022/05/21 01:55:07

otenchwvさん

purchase modafinil without prescription buy modafinil 100mg online


2022/04/08 02:21:09

AndaAudircurnさん

best research tadalafil what is cialis tadalafil 20 mg used for


2022/04/08 05:58:11

Crnnwongeさん

buy cheap purchase uk viagra buy viagra online viagra for sale buy viagra online no prescription


2022/04/09 12:25:17

Dbngplugsさん

20 mg sildenafil how fast does sildenafil work


2022/04/09 20:59:49

Keezexictさん

tadalafil dosage for ed comprar tadalafil generico


2022/04/10 08:03:26

Fnenvunnyさん

what happens if a girl takes viagra brand name viagra


2022/04/10 08:54:38

Ntfbfplugsさん

tadalafil online buy tadalafil online


2022/04/12 02:50:16

Cmmnwongeさん

tadalafil headache cure generic tadalafil 5mg


2022/04/13 14:35:47

AnuoAudircurnさん

pharmacy without prescription us based online pharmacy


2022/04/13 18:26:12

Ckanwongeさん

what are the differences between viagra cialis and levitra levitra vs viagra reviews


2022/04/15 00:09:05

Dsnnplugsさん

pharmacy rx one Viagra with Dapoxetine


2022/04/15 10:38:51

Knrnexictさん

remedies rx pharmacy discount pharmacy card


2022/04/15 19:03:39

Fuupvunnyさん

cheap viagra 100mg canada viagra 50 mg generic


2022/04/15 21:35:53

Nbttplugsさん

buy generic cialis generic cialis cialis for sale on amazon


2022/04/16 19:45:45

Wevgwongeさん

levitra canada pharmacy canadian association of pharmacies


2022/04/16 15:56:57

AnnoAudircurnさん

best over the counter viagra pill buy viagra pharmacy


2022/04/18 04:17:22

Jtnnplugsさん

mectizan stromectol ivermectin dosage humans


2022/04/18 12:04:58

Enrnexictさん

find cheapest cialis pills generic cialis usa


2022/04/18 19:52:53

Auupvunnyさん

tadalafil 20 mg online tadalafil without prescription


2022/04/19 02:06:14

Zbttplugsさん

buy ivermectin pill ivermectin for human


2022/04/20 00:18:15

AnuuAudircurnさん

canadian discount pharmacy belleview fl Reglan


2022/04/20 03:39:55

Wnsnwongeさん

levitra on line generic levitra 40 mg


2022/04/21 11:36:49

Jnnyplugsさん

difference between viagra and cialis cialis one a day


2022/04/21 18:25:44

Ennsexictさん

generic viagra online canada sildenafil tablet brand name in india


2022/04/22 02:46:18

Ahhpvunnyさん

us online cialis generic cialis soft tabs 20mg


2022/04/22 09:46:29

nyyyplugsさん

levitra 20mg filmtabletten levitra list price


2022/04/23 04:40:35

JyhAudircurnさん

canadian pharmacy meds canadian overnight pharmacy


2022/04/23 08:12:35

Wnnhwongeさん

stop canadian pharmacy emails pharmacy drugstore online


2022/04/24 15:55:52

Jmmplugsさん

canadian pharmacies lyrica canada pharmacy


2022/04/24 22:59:57

Eaaqexictさん

medstore online pharmacy pharmacy technician online classes


2022/04/25 07:26:46

Ansnvunnyさん

buy viagra pharmacy 100mg online pharmacy technician jobs from home


2022/04/25 13:37:43

Ntcxplugsさん

pharmacy online shopping direct rx pharmacy


2022/04/29 16:31:14

JyhgAudircurnさん

ivermectin pills moxidectin vs ivermectin https://stromectolujlo.com/


2022/04/29 19:56:08

Wnbhwongeさん

levitra user reviews levitra fda https://glevitrargu.com/


2022/05/01 02:50:45

Jebplugsさん

best price viagra 50 mg how much is sildenafil 50 mg https://sgiviagraikn.com/


2022/05/01 09:39:43

Ebbexictさん

online pharmacy courses canada online pharmacy not requiring prescription https://dtupharmyjn.com/


2022/05/01 17:53:10

Anbnvunnyさん

nizagara sildenafil citrate tablets sildenafil online india https://sildenafilkiol.com/


2022/05/02 00:15:44

Nndnplugsさん

online pharmacy pain medication Lasix https://jzpharmacyukj.com/


2022/05/03 18:54:49

JolwAudircurnさん

purchasing viagra viagra price online india https://aviagrasbt.com/


2022/05/05 04:18:14

Jebnplugsさん

walmart store hours pharmacy Reforge


2022/05/05 11:45:28

Ebbeexictさん

generic cialis coupons buy cialis on line without presciption https://dccialisxvf.com/


2022/05/06 00:47:34

Nndenplugsさん

viagra v cialis v levitra levitra logo https://xclevitradb.com/


2022/05/09 13:02:29

JolwAudircurnさん

viagra online in india brand name viagra https://aviagrasbt.com/


2022/05/09 16:16:27

Wnbhwongeさん

levitra online cheap levitra store https://glevitrargu.com/


2022/05/10 21:38:43

Jebnplugsさん

best ed medication internet pharmacy mexico


2022/05/11 05:00:33

Ebbeexictさん

where can i buy cialis online buy cialis in las vegas https://dccialisxvf.com/


2022/05/11 12:20:35

Anbnvunnyさん

sildenafil same as viagra sildenafil https://sildenafilkiol.com/


2022/05/11 18:03:13

Nndenplugsさん

levitra pe levitra interactions https://xclevitradb.com/


2022/05/13 19:53:38

EvaleenOaOaさん

dissertation editor
what is dissertation defense
dissertation writing services review


2022/05/14 18:50:04

Wnbhwongeさん

how to take levitra for best results levitra vs cialis forum https://glevitrargu.com/


2022/05/14 19:14:07

MaggeeOaOaさん

uk dissertation writing help quotes
chicago dissertation citation
phd dissertation help


2022/05/15 02:31:16

khawmjcfさん

modafinil drug provigil order online


2022/05/15 13:06:41

RegineOaOaさん

steps to writing a dissertation
doctoral dissertation help your
dissertation writing service


2022/05/16 01:08:22

Jebnplugsさん

Flexeril stat rx pharmacy


2022/05/16 12:21:22

KirstiOaOaさん

sample dissertation
creative writing dissertation proposal
cheap dissertation writing help


2022/05/16 15:57:07

Anbnvunnyさん

sildenafil 20 mg cost coupon for sildenafil https://sildenafilkiol.com/


2022/05/18 18:32:36

JolwAudircurnさん

viagra tablet online viagra 20 mg coupon https://aviagrasbt.com/


2022/05/18 21:34:24

hthlnxvsさん

modafinil 200mg over the counter provigil oral


2022/05/18 21:55:49

Wnbhwongeさん

when to take levitra for best results where to buy levitra online https://glevitrargu.com/


2022/05/19 12:53:43

yhhelanlさん

modafinil usa


2022/05/19 14:49:58

pixrwjuwさん

modafinil 100mg usa buy modafinil for sale


2022/05/20 00:39:51

CharlaOaOaさん

writing dissertation objectives
citing a dissertation mla
online dissertation help united kingdom


2022/05/20 04:12:52

Jebnplugsさん

rx discount pharmacy middlesboro ky real canadian pharmacy


2022/05/20 11:11:47

Ebbeexictさん

buying cialis from canada buy cialis pay with paypal canada https://dccialisxvf.com/


2022/05/20 19:01:00

Anbnvunnyさん

cipla sildenafil buy sildenafil citrate online https://sildenafilkiol.com/



コメントを投稿する


お名前


コメント内容





TOP back