我对 exchangelib 有问题。
这是我的代码:
creds = Credentials(
username="domain_name\\username",
password="password")
config = Configuration(server='mail.solutec.fr', credentials=creds)
account = Account(
primary_smtp_address="surname.name@lab-solutec.fr",
autodiscover=False,
config = config,
access_type=DELEGATE)
这是我得到的错误:
SSLError: HTTPSConnectionPool(host='mail.solutec.fr', port=443): Max retries exceeded with url: /EWS/Exchange.asmx (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),))
我可以通过添加以下内容使其工作:
from exchangelib.protocol import BaseProtocol, NoVerifyHTTPAdapter
BaseProtocol.HTTP_ADAPTER_CLS = NoVerifyHTTPAdapter
但这只是绕过安全性,所以这不是我们想要的。
如果我使用手机的共享连接,则没有错误,因此我的企业代理似乎有问题。我看到了有关传输适配器的内容,但并不真正了解如何使其工作。
那么,如果没有这种绕过解决方案,我怎样才能让它很好地工作?
谢谢 !
最佳答案
使用“代理和自定义 TLS 验证”代码
https://pypi.org/project/exchangelib/
我这样做并使用了我内部 PKI 团队的 ca 包(其中包含签署服务器证书的 CA)。
现在你是安全的并且正在覆盖操作系统的证书存储(在我的情况下没有公司的 CA 包)
关于python - exchangelib : can't connect on the server 上的 SSLError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46691545/