Closed oscaroteromar closed 2 years ago
Hi, it's a bit hard to tell with the ***
but it looks like you are trying to connect to foo.com and the server provides a certificate for bar.com. In which case the failure is expected because it is protecting you from a server pretending to be foo.com. I am pretty sure the IMAP server you are connecting to is not configured properly. You haven't mentioned if you tried to connect using another client, like an email client, I would start with that.
Disabling hostname checking or using SSL 2.3 is very insecure and you shouldn't have to do that to connect to an IMAP server in 2022.
This is happening on Docker alpine:3.11 (both running on MacOS Catalina 10.15.5, and on Ubuntu 20.04). When running the following code, just trying to instantiate the client, an exception raises (can’t reveal the server name for business purposes):
Code:
Output:
However,
After some research… I have discovered that creating the object with a custom SSLContext solves the problem:
This might be because the
SSLContext
that usesimapclient
by default has an attributecontext.check_hostname = True
which seems to be the one causing the exception. I wouldn’t like to unset that, it looks safer to keep it that way and the checking should work anyways.Any hint?
Thank you