Exchangelib上的SSLError:无法在服务器上连接

时间:2017-10-11 14:59:06

标签: python proxy ssl-certificate enterprise 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)

这是我得到的错误:

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

但它只是绕过了安全性,所以它不是我们想要的。 如果我使用手机上的共享连接没有错误,所以看起来我的企业代理存在问题。我看到了关于运输适配器的事情,但并不真正了解如何使其工作。

那么,如果没有这种旁路解决方案,我怎样才能使它工作得很好呢?

谢谢!

1 个答案:

答案 0 :(得分:0)

使用代码进行“代理和自定义TLS验证”

https://pypi.org/project/exchangelib/

我这样做了,并使用了我的内部PKI团队的ca捆绑包(其中包含用于签署服务器证书的CA)。

现在,您已经受到保护,并且将覆盖操作系统的证书存储(在我的情况下,该证书存储没有公司的CA捆绑包)