From 41afbb10dfc88b01940f2a109d48cd0fde007cc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Mon, 4 Apr 2022 21:37:41 +0200 Subject: [PATCH] Pass in useful value when raising InvalidCABundle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- slixmpp/xmlstream/xmlstream.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/slixmpp/xmlstream/xmlstream.py b/slixmpp/xmlstream/xmlstream.py index 9077f23c..a687c4f6 100644 --- a/slixmpp/xmlstream/xmlstream.py +++ b/slixmpp/xmlstream/xmlstream.py @@ -35,6 +35,7 @@ import ssl import uuid import warnings import weakref +import collections from contextlib import contextmanager import xml.etree.ElementTree as ET @@ -82,7 +83,7 @@ class InvalidCABundle(Exception): Exception raised when the CA Bundle file hasn't been found. """ - def __init__(self, path: Optional[Path]): + def __init__(self, path: Optional[Union[Path, Iterable[Path]]]): self.path = path @@ -793,8 +794,9 @@ class XMLStream(asyncio.BaseProtocol): if bundle.is_file(): ca_cert = bundle break - if ca_cert is None: - raise InvalidCABundle(ca_cert) + if ca_cert is None and \ + isinstance(self.ca_certs, (Path, collections.abc.Iterable)): + raise InvalidCABundle(self.ca_certs) self.ssl_context.verify_mode = ssl.CERT_REQUIRED self.ssl_context.load_verify_locations(cafile=ca_cert)