I run windows 10 and python 3.11. When I run a pretty standard email sending script I'm getting an SSL error ssl.SSLError: [X509V3: INVALID_CERTIFICATE] invalid certificate (_ssl.c:4035)
I can run the exact same code from another computer with no issues, I have reinstalled certifi
python -m pip install --upgrade --force-reinstall certifi
rebooted several times. I can run email connection code without SSL on the same computer.
The only articles I can find online appear to be related to SSL certificates on MAC OS.
Should I be looking for something in MMC?
Traceback (most recent call last):
File "D:\Python\Projects\webscraping_tours\send_email.py", line 10, in <module>
context = ssl.create_default_context()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Python 3.11.7\Lib\ssl.py", line 775, in create_default_context
context.load_default_certs(purpose)
File "D:\Python 3.11.7\Lib\ssl.py", line 596, in load_default_certs
self._load_windows_store_certs(storename, purpose)
File "D:\Python 3.11.7\Lib\ssl.py", line 588, in _load_windows_store_certs
self.load_verify_locations(cadata=certs)
ssl.SSLError: [X509V3: INVALID_CERTIFICATE] invalid certificate (_ssl.c:4035)
I found the solution here: https://github.com/python/cpython/issues/108721
In certmgr.msc > intermediate certification authorities> (filename) 'TPS Self-Signed OAUTH Signing Certificate(PC name)'. I had 4 copies of this file, some with older PC names. Apparently they duplicate when the PC is renamed. This is likely where the corruption comes from. I deleted 3 copies of 4 files and rebooted. It did not work until I had deleted the oldest 3 copies.