Merge branch 'exn-invalidcabundle-arg' into 'master'
Pass in useful value when raising InvalidCABundle See merge request poezio/slixmpp!195
This commit is contained in:
commit
f7902d056e
@ -35,6 +35,7 @@ import ssl
|
|||||||
import uuid
|
import uuid
|
||||||
import warnings
|
import warnings
|
||||||
import weakref
|
import weakref
|
||||||
|
import collections
|
||||||
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
@ -82,7 +83,7 @@ class InvalidCABundle(Exception):
|
|||||||
Exception raised when the CA Bundle file hasn't been found.
|
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
|
self.path = path
|
||||||
|
|
||||||
|
|
||||||
@ -793,8 +794,9 @@ class XMLStream(asyncio.BaseProtocol):
|
|||||||
if bundle.is_file():
|
if bundle.is_file():
|
||||||
ca_cert = bundle
|
ca_cert = bundle
|
||||||
break
|
break
|
||||||
if ca_cert is None:
|
if ca_cert is None and \
|
||||||
raise InvalidCABundle(ca_cert)
|
isinstance(self.ca_certs, (Path, collections.abc.Iterable)):
|
||||||
|
raise InvalidCABundle(self.ca_certs)
|
||||||
|
|
||||||
self.ssl_context.verify_mode = ssl.CERT_REQUIRED
|
self.ssl_context.verify_mode = ssl.CERT_REQUIRED
|
||||||
self.ssl_context.load_verify_locations(cafile=ca_cert)
|
self.ssl_context.load_verify_locations(cafile=ca_cert)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user