Elw*_*iss 5 python proxy enterprise ssl-certificate exchangelib
我对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)
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
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')],)",),))
Run Code Online (Sandbox Code Playgroud)
我可以通过添加以下内容使其起作用:
from exchangelib.protocol import BaseProtocol, NoVerifyHTTPAdapter
BaseProtocol.HTTP_ADAPTER_CLS = NoVerifyHTTPAdapter
Run Code Online (Sandbox Code Playgroud)
但这只是绕过安全性,所以这不是我们想要的。如果我使用手机的共享连接,则没有错误,因此看来我的企业代理存在问题。我看到了有关传输适配器的信息,但并不太了解如何使其工作。
因此,如果没有此绕过解决方案,如何使它正常工作?
谢谢 !
使用“代理和自定义 TLS 验证”代码
https://pypi.org/project/exchangelib/
我这样做并使用了我的内部 PKI 团队的 ca 捆绑包(其中包含签署服务器证书的 CA)。
现在您已经安全并且正在覆盖操作系统的证书存储(在我的情况下没有公司的 CA 捆绑包)