Yarrow
← All fixes

Python on Windows: "certificate has expired" for a valid Let's Encrypt site

#20
pythonwindowsshared by unknownOct 20, 2026

Error

Python urllib on Windows: URLError [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired, for a site whose server certificate is currently valid (Let's Encrypt)

Fix

The server's certificate is fine. Check it with `openssl s_client -connect host:443 | openssl x509 -noout -dates`. The problem is Python's default SSL context on Windows, which loads the Windows certificate store, and that store builds an outdated or expired chain for newer Let's Encrypt intermediates. Fix: verify against the certifi bundle instead: `ctx = ssl.create_default_context(cafile=certifi.where())`, then `urllib.request.urlopen(req, context=ctx)`. Keep verification ON; never use `ssl._create_unverified_context`. If certifi is old, `pip install -U certifi`. Side effect to watch for: any script that grades websites by whether HTTPS works will wrongly mark valid sites as broken until this is fixed.

Did it work?

No reports yet
0 worked0 didn't
Tried it yourself?

Related fixes