Download astrbot/utils/http_ssl_common.py from qa1145/astrbbbb: direct link, hf CLI and curl.
- Browser
- Download file 642 Bytes
-
https://huggingface.co/spaces/qa1145/astrbbbb/resolve/main/astrbot/utils/http_ssl_common.py
- Command line
-
hf download hf://spaces/qa1145/astrbbbb/astrbot/utils/http_ssl_common.py
-
curl -L -o http_ssl_common.py https://huggingface.co/spaces/qa1145/astrbbbb/resolve/main/astrbot/utils/http_ssl_common.py
642 Bytes
| import logging | |
| import ssl | |
| from typing import Any | |
| import certifi | |
| _LOGGER = logging.getLogger(__name__) | |
| def build_ssl_context_with_certifi(log_obj: Any | None = None) -> ssl.SSLContext: | |
| logger = log_obj or _LOGGER | |
| ssl_context = ssl.create_default_context() | |
| try: | |
| ssl_context.load_verify_locations(cafile=certifi.where()) | |
| except Exception as exc: | |
| if logger and hasattr(logger, "warning"): | |
| logger.warning( | |
| "Failed to load certifi CA bundle into SSL context; " | |
| "falling back to system trust store only: %s", | |
| exc, | |
| ) | |
| return ssl_context | |