diff options
author | mathieui <mathieui@mathieui.net> | 2022-04-05 19:42:06 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2022-04-05 19:42:06 +0200 |
commit | f7902d056ec995f7f373df4c865d644fa2d0bbfd (patch) | |
tree | 9b024276f88dcbe4bfdfb5b37150c098014a6d0f | |
parent | aca4addb9ceb8b70944c4af76ee6d12cc0a82d64 (diff) | |
parent | 41afbb10dfc88b01940f2a109d48cd0fde007cc9 (diff) | |
download | slixmpp-f7902d056ec995f7f373df4c865d644fa2d0bbfd.tar.gz slixmpp-f7902d056ec995f7f373df4c865d644fa2d0bbfd.tar.bz2 slixmpp-f7902d056ec995f7f373df4c865d644fa2d0bbfd.tar.xz slixmpp-f7902d056ec995f7f373df4c865d644fa2d0bbfd.zip |
Merge branch 'exn-invalidcabundle-arg' into 'master'
Pass in useful value when raising InvalidCABundle
See merge request poezio/slixmpp!195
-rw-r--r-- | slixmpp/xmlstream/xmlstream.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/slixmpp/xmlstream/xmlstream.py b/slixmpp/xmlstream/xmlstream.py index 2e81c506..18143f87 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) |