Issue: How can I fix the appearing python error while renewing a Let’s Encrypt certificate?
As you may have noticed, this blog features a Let’s Encrypt certificate. Let’s Encrypt only allows certificates to be authorized for up to 3 months. While this isn’t that big of a problem for most users (you can renew the certificate quite easily) I managed to run into a error message regarding python. In this quick tip, I’ll show you how to avoid this error.
Step 1 – Updating the certificate
With this simple command, you’ll be able to start the automatic renewal of the certificate. You’ll most likely ran this already:
/opt/letsencrypt/letsencrypt-auto renew
Now if you’ll see an error message like this at the end, there’s a big chance Step 2 will fix your problem.
Command "/root/.local/share/letsencrypt/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-zwKnXW/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace(' ', ' '), __file__, 'exec'))" install --record /tmp/pip-GLbPUy-record/install-record.txt --single-version-externally-managed --compile --install-headers /root/.local/share/letsencrypt/include/site/python2.7/cryptography" failed with error code 1 in /tmp/pip-build-zwKnXW/cryptography /root/.local/share/letsencrypt/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning 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.
Step 2 – Fixing the error
Now what this error message won’t tell you, is that Python just ran out of memory. This seems to be a common problem on less powerful setups. But fear not, there’s a simple solution to this problem: a swap file. We’re setting up a file, which acts as a swap partition for memory. To achieve this, simple paste these four commands into your console:
sudo dd if=/dev/zero of=/swapfile bs=1024 count=524288 sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile
Now just rerun the command from Step 1 and you’ll find it finishing without this error. Your certificate is now updated. To disable the swap file run this command and you’re back to your previous configuration:
sudo swapoff /swapfile