Code Yarns ‍👨‍💻
Tech Blog ❖ Personal Blog

Calibre SSL CERTIFICATE_VERIFY_FAILED error

📅 2022-Mar-17 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ calibre, error ⬩ 📚 Archive

Problem

I tried to use the Fetch News feature in Calibre to download a news source which had a RSS feed. The download job finished quickly, but the generated ebook had no pages, but had this error:

Traceback (most recent call last):
  File "mechanize\_urllib2_fork.py", line 1236, in do_open
  File "http\client.py", line 1255, in request
  File "http\client.py", line 1301, in _send_request
  File "http\client.py", line 1250, in endheaders
  File "http\client.py", line 1010, in _send_output
  File "http\client.py", line 950, in send
  File "http\client.py", line 1424, in connect
  File "ssl.py", line 500, in wrap_socket
  File "ssl.py", line 1040, in _create
  File "ssl.py", line 1309, in do_handshake
  ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1123)

The same RSS feed or webpage opened without any problem in Firefox, Chrome, Edge and Internet Explorer.

Solution

This error is apparently due to an expired root certificate from Let’s Encrypt that might be stored in your Windows.

Calibre uses the Mechanize library to create a browser object and downloads pages using that. That object uses the root certificates from Windows and so is affected by the expired root certificate. The browsers have their own certificate store and so they are unaffected.

To delete the expired certificate:

After this, Calibre should be able to download the news.

References

Tried with: Calibre 5.38