requests/exchangelib SSLError - 主机名 'outlook.office.de' 不匹配

requests/exchangelib SSLError - hostname 'outlook.office.de' doesn't match either of

我在连接 Microsoft Exchange 时遇到问题。它是最近开始的。问题是我不知道去哪里寻找解决方案。

问题是我正在尝试连接到 office.de,但证书现在似乎不包含此域。

在哪里寻找 solution/bug?:

  1. 我的电脑(Ubuntu 20.04)
  2. python 请求
  3. python 交换库
  4. 微软证书(临时签发)

回溯:

Traceback (most recent call last):
    account = Account(
  File "/home/milano/.virtualenvs/xx-xxx-xxxx/lib/python3.9/site-packages/exchangelib/account.py", line 126, in __init__
    self.protocol = Protocol(config=config)
  File "/home/milano/.virtualenvs/xx-xxx-xxxx/lib/python3.9/site-packages/exchangelib/protocol.py", line 405, in __call__
    raise e
  File "/home/milano/.virtualenvs/xx-xxx-xxxx/lib/python3.9/site-packages/exchangelib/protocol.py", line 400, in __call__
    protocol = super().__call__(*args, **kwargs)
  File "/home/milano/.virtualenvs/xx-xxx-xxxx/lib/python3.9/site-packages/exchangelib/protocol.py", line 434, in __init__
    self.config.auth_type = self.get_auth_type()
  File "/home/milano/.virtualenvs/xx-xxx-xxxx/lib/python3.9/site-packages/exchangelib/protocol.py", line 439, in get_auth_type
    auth_type, api_version_hint = get_service_authtype(
  File "/home/milano/.virtualenvs/xx-xxx-xxxx/lib/python3.9/site-packages/exchangelib/transport.py", line 155, in get_service_authtype
    raise TransportError(str(e)) from e
exchangelib.errors.TransportError: HTTPSConnectionPool(host='outlook.office.de', port=443): Max retries exceeded with url: /EWS/Exchange.asmx (Caused by SSLError(SSLCertVerificationError("hostname 'outlook.office.de' doesn't match either of '*.internal.outlook.com', '*.outlook.com', 'outlook.com', 'office365.com', '*.office365.com', '*.outlook.office365.com', '*.office.com', 'outlook.office.com', 'substrate.office.com', 'attachment.outlook.live.net', 'attachment.outlook.office.net', 'attachment.outlook.officeppe.net', 'attachments.office.net', '*.clo.footprintdns.com', '*.nrb.footprintdns.com', 'ccs.login.microsoftonline.com', 'ccs-sdf.login.microsoftonline.com', 'substrate-sdf.office.com', 'attachments-sdf.office.net', '*.live.com', 'mail.services.live.com', 'hotmail.com', '*.hotmail.com'")))

The problem is that I'm trying to connect to office.de but the certificate seems not to include this domain now.

这是正确的。检查浏览器将显示这不是 Python 的问题,而是网站是这样设置的,即 浏览器也会报错。

虽然正式记录在 Office 365 Germany endpoints 上使用,但似乎域 office.de 未设置为与此域名一起使用 HTTPS。

由于 outlook.office.de 目前只是 outlook.office.com 的别名 (DNS CNAME),我的猜测是记录的域不打算通过 HTTPS 直接访问,但记录它们只是为了获取必要的 IP 范围。在内部,MS Exchange 可能会改用 office.com 域,从而成功匹配证书。