ラベル lets-encrypt の投稿を表示しています。 すべての投稿を表示
ラベル lets-encrypt の投稿を表示しています。 すべての投稿を表示

2016年6月25日土曜日

Let's Encryptの cronによる実行が動かなくなった時の対策

certbot (Let's Encrypt)を Amazon Linuxにインストールの後日談。
OSはAmazon linux。

cronの結果がメールで送られてきた。

Checking for new version...
Upgrading certbot-auto 0.6.0 to 0.7.0...
Replacing certbot-auto...
Creating virtual environment...
./certbot/certbot-auto: line 530: virtualenv: command not found

cronを再実行してみる。
WARNING: Amazon Linux support is very experimental at present...
if you would like to work on improving it, please ensure you have backups
and then run this script again with the --debug flag!

言われた通りにコマンドを変更。
./certbot/certbot-auto renew --debug && sudo service httpd reload

再実行。
Bootstrapping dependencies via Amazon Linux...
yum is /usr/bin/yum
Loaded plugins: priorities, update-motd, upgrade-helper
Package gcc-4.8.3-3.20.amzn1.noarch already installed and latest version
Package dialog-1.1-9.20080819.1.5.amzn1.x86_64 already installed and latest version
Package augeas-libs-1.0.0-5.7.amzn1.x86_64 already installed and latest version
Package 1:openssl-1.0.1k-14.91.amzn1.x86_64 already installed and latest version
Package 1:openssl-devel-1.0.1k-14.91.amzn1.x86_64 already installed and latest version
Package libffi-devel-3.0.13-11.4.amzn1.x86_64 already installed and latest version
Package system-rpm-config-9.0.3-42.27.amzn1.noarch already installed and latest version
Package ca-certificates-2015.2.6-65.0.1.15.amzn1.noarch already installed and latest version
Package python27-2.7.10-4.120.amzn1.x86_64 already installed and latest version
Package python27-devel-2.7.10-4.120.amzn1.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package python27-pip.noarch 0:6.1.1-1.21.amzn1 will be installed
---> Package python27-tools.x86_64 0:2.7.10-4.120.amzn1 will be installed
---> Package python27-virtualenv.noarch 0:12.0.7-1.12.amzn1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
 Package                 Arch       Version                 Repository     Size
================================================================================
Installing:
 python27-pip            noarch     6.1.1-1.21.amzn1        amzn-main     1.9 M
 python27-tools          x86_64     2.7.10-4.120.amzn1      amzn-main     706 k
 python27-virtualenv     noarch     12.0.7-1.12.amzn1       amzn-main     2.0 M
Transaction Summary
================================================================================
Install  3 Packages
Total download size: 4.6 M
Installed size: 11 M
Is this ok [y/d/N]: Exiting on user command
Your transaction was saved, rerun it with:
 yum load-transaction /tmp/yum_save_tx.2016-06-22.11-17.hYs7z_.yumtx
Could not install OS dependencies. Aborting bootstrap!

cronでなく手動で実行し、パッケージをインストール
./certbot/certbot-auto renew --debug

正常終了。
以降はcronでも"--debug"無しでも大丈夫になったが、"--debug"を付けておいた方が無難?

2016年5月21日土曜日

certbot (Let's Encrypt)を Amazon Linuxにインストール


以前一度挫折した(古いAmazon Linuxをアップデートして使っているためだと思われる)が、certbotに改名後に試してみたら、できた。


前提

  • gitはインストール済み
  • WebサーバはApache



手順

  1. sudo easy_install pip
  2. sudo pip install --upgrade pip
  3. sudo /usr/local/bin/pip install --upgrade virtualenv
  4. (作業用ディレクトリで)
    git clone https://github.com/certbot/certbot
  5. cd certbot
  6. ./certbot-auto certonly --webroot -w /var/www/html -d ドメイン名 --agree-tos -m メールアドレス --debug
  7. /etc/httpd/conf.d/ssl.confの下記箇所を変更する。(Apache2.4.8より前のバージョン場合は微妙に違うので参考サイト参照。)
    SSLCertificateFile /etc/letsencrypt/live/ドメイン名/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/ドメイン名/privkey.pem
  8. httpdを再起動


証明書の自動更新
証明書の期限は90日なので、cronで定期更新させる。cronがメールを飛ばすように設定してあれば結果がメールで来る。

(例:月に1回更新する場合。日時は月初にすると混雑しそうなので、適当にずらした方がよいかも。)
45 3 12 * * ./certbot/certbot-auto renew && sudo service httpd reload

(2016/6/25 追記)
--debugも付けた方がよいかも?参考→Let's Encryptの cronによる実行が動かなくなった時の対策
(追記終わり)

期限まで30日以上ある場合は更新されない。それでも更新したい場合は--force-renewオプションを付ける。
上記例を試した時はまだ更新されなかったので、本当にこれでよいかはその日が来てから確認する。(--debug無しとか大丈夫か?タイミングによっては、月イチだと期限切れになるケースがあるかも?)


備考的な

  • Aapcheは停止しなくても大丈夫。(webrootオプションを使う場合はいいらしい。)
  • 証明書生成時にポート443は開いてなくても大丈夫。
  • /var/www/htmlに.well-knownディレクトリが残る。消してもいいのかな?



さよなら自己署名!さよならオレオレ証明書!


参考



ブログ アーカイブ

tags