無料SSLで有名なLet’s encryptを、利用させて頂いており、
それの有効期限3ヶ月と短く、その有効期限が迫ったので、更新対応した際のメモ
導入はほぼ200%こちらのサイト様を参考にさせていただきましたm( _ _ ; )m
http://qiita.com/sak_2/items/ff835b669c0a7e110b09
そもそも自動化しろよって話ですが、
手動で更新した際のメモw
1. 恐らく導入時に使ったletsencrypt-autoというファイルを探す。
2. 生成したキーファイル類を確認しておく、必要であればバックアップも
$ cd /etc/letsencrypt/live/blog.4star.link/
cert.pem chain.pem fullchain.pem privkey.pem
3. それぞれのpemファイルがシンボリックで参照されているので、それがnginxで設定しているファイルと同じか確認
cert.pem -> ../../archive/blog.4star.link/cert1.pem
chain.pem -> ../../archive/blog.4star.link/chain1.pem
fullchain.pem -> ../../archive/blog.4star.link/fullchain1.pem
privkey.pem -> ../../archive/blog.4star.link/privkey1.pem
4. で1.のコマンド実行し更新!
$ ./letsencrypt-auto renew
エラーがでた
$ ./letsencrypt-auto renew
Saving debug log to /var/log/letsencrypt/letsencrypt.log
-------------------------------------------------------------------------------
Processing /etc/letsencrypt/renewal/blog.4star.link.conf
-------------------------------------------------------------------------------
Cert is due for renewal, auto-renewing...
Starting new HTTPS connection (1): acme-v01.api.letsencrypt.org
Renewing an existing certificate
Performing the following challenges:
tls-sni-01 challenge for blog.4star.link
-------------------------------------------------------------------------------
Port 443 is already in use by another process. This will prevent us from binding
to that port. Please stop the process that is populating the port in question
and try again. For automated renewal, you may want to use a script that stops
and starts your webserver. You can find an example at
https://certbot.eff.org/docs/using.html#renewal . Alternatively you can use the
webroot plugin to renew without needing to stop and start your webserver.
-------------------------------------------------------------------------------
Cleaning up challenges
Attempting to renew cert from /etc/letsencrypt/renewal/blog.4star.link.conf produced an unexpected error: At least one of the (possibly) required ports is already taken.. Skipping.
All renewal attempts failed. The following certs could not be renewed:
/etc/letsencrypt/live/blog.4star.link/fullchain.pem (failure)
1 renew failure(s), 0 parse failure(s)
必要なポートが既に使われているらしい。
ポートチェック
$ netstat -tanplsof -i:80
nginxで使っているので一旦停止(サービスが止まるので注意!
$ service nginx stop
再びrenew!
$ ./letsencrypt-auto renew
Saving debug log to /var/log/letsencrypt/letsencrypt.log
-------------------------------------------------------------------------------
Processing /etc/letsencrypt/renewal/blog.4star.link.conf
-------------------------------------------------------------------------------
Cert is due for renewal, auto-renewing...
Starting new HTTPS connection (1): acme-v01.api.letsencrypt.org
Renewing an existing certificate
Performing the following challenges:
tls-sni-01 challenge for blog.4star.link
-------------------------------------------------------------------------------
Port 443 is already in use by another process. This will prevent us from binding
to that port. Please stop the process that is populating the port in question
and try again. For automated renewal, you may want to use a script that stops
and starts your webserver. You can find an example at
https://certbot.eff.org/docs/using.html#renewal . Alternatively you can use the
webroot plugin to renew without needing to stop and start your webserver.
-------------------------------------------------------------------------------
Cleaning up challenges
Attempting to renew cert from /etc/letsencrypt/renewal/blog.4star.link.conf produced an unexpected error: At least one of the (possibly) required ports is already taken.. Skipping.
All renewal attempts failed. The following certs could not be renewed:
/etc/letsencrypt/live/blog.4star.link/fullchain.pem (failure)
1 renew failure(s), 0 parse failure(s)
また同じエラーが。。。
さらにもう一回!
どりゃっっxさらにもう一回!
ぐああーーっしゃいさらにもう1っかい!
。。。。
。。。。。
何度か同じエラーがでたあと、
$ ./letsencrypt-auto renew
Saving debug log to /var/log/letsencrypt/letsencrypt.log
-------------------------------------------------------------------------------
Processing /etc/letsencrypt/renewal/blog.4star.link.conf
-------------------------------------------------------------------------------
Cert is due for renewal, auto-renewing...
Starting new HTTPS connection (1): acme-v01.api.letsencrypt.org
Renewing an existing certificate
Performing the following challenges:
tls-sni-01 challenge for blog.4star.link
Waiting for verification...
Cleaning up challenges
Generating key (2048 bits): /etc/letsencrypt/keys/0001_key-certbot.pem
Creating CSR: /etc/letsencrypt/csr/0001_csr-certbot.pem
-------------------------------------------------------------------------------
new certificate deployed without reload, fullchain is
/etc/letsencrypt/live/blog.4star.link/fullchain.pem
-------------------------------------------------------------------------------
Congratulations, all renewals succeeded. The following certs have been renewed:
/etc/letsencrypt/live/blog.4star.link/fullchain.pem (success)
成功ーーーーーーー!
最高ーーーーーーー!
わっほい!
で
$ service nginx start
証明書が更新されていない。。。。
生成されたpemファイルをチェック。。。
pemが複数連番になってつくられている、、
/archive/blog.4star.link/cert1.pem
/archive/blog.4star.link/cert2.pem
僕の場合archiveのファイルをnginx.confに指定していたので、
生成された番号のつきの名前の方を変更。。
人力でファイルを変更。。。w
nginx.conf
ssl_certificate /etc/letsencrypt/archive/blog.4star.link/fullchain**2**.pem;
ssl_certificate_key /etc/letsencrypt/archive/blog.4star.link/privkey**2**.pem;
ssl_trusted_certificate /etc/letsencrypt/archive/blog.4star.link/fullchain**2**.pem;
あとは、
せいや。。。!!!!
$ service nginx start
更新が終わるとlive側にあるシンボリックリンクが更新されます。
/etc/letsencrypt/live/blog.4star.link/fullchain.pem → /etc/letsencrypt/archive/blog.4star.link/fullchain**2**.pem
nginx.confで指定するファイルをlive側にするとこの先変更が要らなくて楽でいいですよ
pi-chanさん コメントありがとうございます!!!嬉泣
live側に!そんな方法があるんですね!早速使わせて頂きます。
ご丁寧に例文までありがとうございます、感謝!
おかげさまで、liveフォルダで簡単で自動更新できるようになったので、cronで自動更新する方法メモしておきます。
# とりえあず毎月1日4時にlets encrypltのSSLを自動更新。注意:一時的にnginxをストップする必要あり
00 04 01 * * /etc/init.d/nginx stop && /root/my_ssl_history/letsencrypt/letsencrypt-auto renew –force-renew && /etc/init.d/nginx start
どうもありがとうございました