'[SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:无法获取本地颁发者证书 (_ssl.c:997)')))
'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')))
使用此代码时,会生成以下错误:
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)')))
如何提供本地颁发者证书或以其他方式解决问题?
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 位置:from requests.utils import DEFAULT_CA_BUNDLE_PATH;打印(DEFAULT_CA_BUNDLE_PATH)
编辑 cacert.pem 文件并将您的域验证证书粘贴到文件末尾。
保存文件并享受请求!
exchangelib 使用 requests
来执行实际的 HTTP 请求。这意味着您可以设置 REQUESTS_CA_BUNDLE
环境变量。参见 How to force requests use the certificates on my ubuntu system
使用此代码时,会生成以下错误:
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)')))
如何提供本地颁发者证书或以其他方式解决问题?
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 位置:from requests.utils import DEFAULT_CA_BUNDLE_PATH;打印(DEFAULT_CA_BUNDLE_PATH) 编辑 cacert.pem 文件并将您的域验证证书粘贴到文件末尾。 保存文件并享受请求!
exchangelib 使用 requests
来执行实际的 HTTP 请求。这意味着您可以设置 REQUESTS_CA_BUNDLE
环境变量。参见 How to force requests use the certificates on my ubuntu system