Error on verify as str. (#3418)

This commit is contained in:
Tom Christie 2024-11-28 11:46:59 +00:00 committed by GitHub
parent 47f4a96ffa
commit ce7e14da27
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -31,6 +31,14 @@ def create_ssl_context(verify: ssl.SSLContext | bool = True) -> ssl.SSLContext:
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE
return ssl_context
elif isinstance(verify, str): # pragma: nocover
# Explicitly handle this deprecated usage pattern.
msg = (
"verify should be a boolean or SSLContext, since version 0.28. "
"Use `verify=ssl.create_default_context(cafile=...)` "
"or `verify=ssl.create_default_context(capath=...)`."
)
raise RuntimeError(msg)
return verify