首页 > 解决方案 > requests/exchangelib SSLError - 主机名“outlook.office.de”不匹配

问题描述

我在连接到Microsoft Exchange. 它是最近开始的。问题是我不确定在哪里寻找解决方案。

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

在哪里寻找解决方案/错误?:

  1. 我的电脑(Ubuntu 20.04)
  2. 蟒蛇请求
  3. 蟒蛇交换库
  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'")))

标签: pythonsslpython-requestsssl-certificateexchangelib

解决方案


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

这是对的。检查浏览器将表明这不是 Python 的问题,而是该站点是这样设置的,即浏览器也会抱怨。

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

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


推荐阅读