MAIF / melusine

📧 Melusine: Use python to automatize your email processing workflow

Home Page:https://maif.github.io/melusine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SSL Certificate Error

Maxime-POULAIN-Verlingue opened this issue · comments

Hey !

When we tried to connect to the server where we want to get our mails, we got some errors due to SSL Certificate Error :

SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1131)

MaxRetryError: HTTPSConnectionPool(host='mail.verlingue.fr', port=443): Max retries exceeded with url: /EWS/Exchange.asmx (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1131)')))

SSLError: HTTPSConnectionPool(host='mail.verlingue.fr', port=443): Max retries exceeded with url: /EWS/Exchange.asmx (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1131)')))

TransportError: HTTPSConnectionPool(host='mail.verlingue.fr', port=443): Max retries exceeded with url: /EWS/Exchange.asmx (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1131)')))

This is probably due to the version of the mailbox server we use in our company, because when I tried to connect to an Office 365 mailbox, I hadn't the same issue.
To fix that, we added these lines at the beginning of melusine/connectors/exchange.py, and it works.

from exchangelib.protocol import BaseProtocol, NoVerifyHTTPAdapter
BaseProtocol.HTTP_ADAPTER_CLS = NoVerifyHTTPAdapter

Mailbox Server : Microsoft Exchange Server 2010

Python version : 3.8.12

Melusine version : 2.3.1

Operating System : Windows

Hello,
Thanks a lot for posting your solutions :)

It seems like the lines you added do not interact with the ExchangeConnector class itself.
(I guess it modifies some general exchangelib configurations)

I am wondering if it would works if you ran these lines somewhere in your local code instead of running it in
melusine/connectors/exchange.py

I'd try running it before you instantiate the exchangelib Configuration object (or maybe before importing melusine?)
I could be wrong but I can't think of a reason why you'd need to have it inside the module exchange.py

Let us know how it goes :)

Hello,
Thanks for your reply !

I tried to put the two lines at the beginning of the script where we instantiate the exchangelib Configuration object, and It works ! It seems we don't need to write them in the "exchange.py" file.

If people have the same problem as we had, this solution may works.

Have a good day !