PCがあれば何でもできる!

へっぽこアラサープログラマーが、覚えたての知識を得意げにお届けします

Let's Encryptが急に動かなくなった件(THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE.)

Let's EncryptでSSL化したサイトに、もうすぐ証明書の期限切れが来るというメールが。

cronで期限の更新も自動化したはずなのに…。

ということで調べてみると、以下のようなエラーが発生している。

./certbot-auto certonly --webroot -w /usr/share/nginx/html -d www.xxx.com --renew-by-default
〜〜〜 省略 〜〜〜
Creating virtual environment...
Installing Python packages...
Had a problem while installing Python packages:
〜〜〜 省略 〜〜〜
Collecting certbot==0.8.1 (from -r /tmp/tmp.lHgsdDzKb3/letsencrypt-auto-requirements.txt (line 187))
  Downloading certbot-0.8.1-py2-none-any.whl (217kB)
Collecting certbot-apache==0.8.1 (from -r /tmp/tmp.lHgsdDzKb3/letsencrypt-auto-requirements.txt (line 190))
  Downloading certbot_apache-0.8.1-py2-none-any.whl (103kB)
Requirement already satisfied (use --upgrade to upgrade): setuptools>=1.0 in /root/.local/share/letsencrypt/lib/python2.7/site-packages (from cryptography==1.2.3->-r /tmp/tmp.lHgsdDzKb3/letsencrypt-auto-requirements.txt (line 35))
THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
    pycparser==2.14 from https://pypi.python.org/packages/74/0e/111a4349e81e2a9846129e0357e154b496559799ec34a6b27bc677247bfa/pycparser-2.14-py2.py3-none-any.whl#md5=130e8dc5b640d9339ee4056da0cdc73a (from -r /tmp/tmp.lHgsdDzKb3/letsencrypt-auto-requirements.txt (line 11)):
        Expected sha256 7959b4a74abdc27b312fed1c21e6caf9309ce0b29ea86b591fd2e99ecdf27f73
             Got        52bcedd9180999fc7f3128b4b89ce638ffc0ffcbd136873379d5a37e4f9e7932

You are using pip version 8.0.3, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

どうやらPythonパッケージのpycparserのハッシュが不一致となり、エラーになってしまう様子。

下記の記事で、同様の現象が発生しているとの報告が多々あり、解決法まで記載されました。

こちらが10/3からの記事で、私がこの問題に直面したのも10/3なので、偶然にもリアルタイムで体験してしまったようです^^;

解決法をまとめると、certbot-autoのスクリプトを以下のように修正。

# 修正前
pyparser==2.14 \
--hash=sha256:7959b4a74abdc27b312fed1c21e6caf9309ce0b29ea86b591fd2e99ecdf27f7

# 修正後
pyparser==2.14 \
--hash=sha256:7959b4a74abdc27b312fed1c21e6caf9309ce0b29ea86b591fd2e99ecdf27f73 \
--no-binary pycparser

pythonに詳しくないので、修正内容の詳細まではご説明できません!