I've been having some weird SSL/TLS issues with my web app as well as code I execute in the Python shell. I'm trying to connect to my email using imaplib and it's giving me an SSL/TLS issue and when I try to hit my API through an always-on task (using requests) sometimes it's giving me SSL issues as well.
For the always-on task I set:
requests.get('https://myapi.com', verify=False)
And this seemed to work, however, it gives me a warning about not doing this. Also for the imaplib, I have ran this same exact code on my machine and it connects to the email fine, however, when executing this in Django Shell/normal Python Shell in my PythonAnywhere it gives me an error.
Here is part of the trace:
return imaplib.IMAP4_SSL(self._host, self._port, self._keyfile, self._certfile, self._ssl_context,
File "/usr/local/lib/python3.10/imaplib.py", line 1323, in __init__
IMAP4.__init__(self, host, port, timeout)
File "/usr/local/lib/python3.10/imaplib.py", line 202, in __init__
self.open(host, port, timeout)
File "/usr/local/lib/python3.10/imaplib.py", line 1336, in open
IMAP4.open(self, host, port, timeout)
File "/usr/local/lib/python3.10/imaplib.py", line 312, in open
self.sock = self._create_socket(timeout)
File "/usr/local/lib/python3.10/imaplib.py", line 1327, in _create_socket
return self.ssl_context.wrap_socket(sock,
File "/usr/local/lib/python3.10/ssl.py", line 513, in wrap_socket
return self.sslsocket_class._create(
File "/usr/local/lib/python3.10/ssl.py", line 1071, in _create
self.do_handshake()
File "/usr/local/lib/python3.10/ssl.py", line 1342, in do_handshake
self._sslobj.do_handshake()
ConnectionResetError: [Errno 104] Connection reset by peer