' [ssl:cielder_verify_failed]证书验证失败:无法获取本地发行者证书(_SSL.C:997))')))))))
使用此代码时,会生成以下错误:
fressangelib.errors.transporterror:httpsconnectionpool(host ='mail.rt.yu',端口= 443):最大恢复 超过url:/ews/exchange.asmx(由sslerror引起(sslcertverificationerror引起(1,'[ssl:cetiral_verify_failed]证书验证验证失败:无法获得本地发行者证书(_sssl.c:997)')))
> p>> p>>>
超过url:/ews/exchange.asmx(由sslerror引起(sslcertverificationerror引起(1,'[ssl : 本地发行人证书还是以其他方式解决了问题?
from exchangelib import Credentials,DELEGATE, IMPERSONATION, Account,Message, Mailbox, FileAttachment,Configuration
credentials = Credentials(username=r'sinai\afgggn.t.auu',
password='SSft@y155')
config = Configuration(server='mail.te.eg', credentials=credentials)
account = Account(primary_smtp_address='afgggn.t.auu', config=config,
autodiscover=False, access_type=DELEGATE)
for item in account.inbox.all().order_by('-datetime_received')[:100]:
print(item.subject, item.sender, item.datetime_received)
更新 这是在搜索解决方案的麻烦之后解决问题的解决方案 将域验证证书下载为 *.crt或 *PEM文件 打开编辑器中的文件,然后将其内容复制到剪贴板 查找您的cacert.pem位置:从请求。打印(default_ca_bundle_path) 编辑cacert.pem文件,并在文件末尾粘贴域验证证书。 保存文件并享受请求!
When using this code, the following error is generated:
exchangelib.errors.TransportError: HTTPSConnectionPool(host='mail.rt.yu', port=443): Max retries
exceeded with url: /EWS/Exchange.asmx (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')))
How can I provide a local issuer certificate or otherwise solve the problem?
from exchangelib import Credentials,DELEGATE, IMPERSONATION, Account,Message, Mailbox, FileAttachment,Configuration
credentials = Credentials(username=r'sinai\afgggn.t.auu',
password='SSft@y155')
config = Configuration(server='mail.te.eg', credentials=credentials)
account = Account(primary_smtp_address='afgggn.t.auu', config=config,
autodiscover=False, access_type=DELEGATE)
for item in account.inbox.all().order_by('-datetime_received')[:100]:
print(item.subject, item.sender, item.datetime_received)
update
This is the solution to the problem after the trouble of searching for solutions
download the domain validation certificate as *.crt or *pem file
open the file in editor and copy it's content to clipboard
find your cacert.pem location: from requests.utils import DEFAULT_CA_BUNDLE_PATH; print(DEFAULT_CA_BUNDLE_PATH)
edit the cacert.pem file and paste your domain validation certificate at the end of the file.
Save the file and enjoy requests!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Exchangelib使用
请求
来执行实际的HTTP请求。这意味着您可以设置requests_ca_bundle
环境变量。请参阅 Ubuntu系统exchangelib uses
requests
to do the actual HTTP requests. This means you can set theREQUESTS_CA_BUNDLE
environment variable. See How to force requests use the certificates on my ubuntu system我在Ubuntu 22.04上遇到了同样的问题。就我而言,我的/etc/ssl/certs/ca-certificates.crt无效。我制作了它的副本,并用 https://curl.haxx.se/ca/ca/ cacert.pem 。这解决了错误。
I got the same issue on Ubuntu 22.04. And in my case my /etc/ssl/certs/ca-certificates.crt was not valid. I made a copy of it and replaced it with https://curl.haxx.se/ca/cacert.pem. This resolved the error.