$ show certifi/python-certifi
Certifi is a minimal Python library that provides Mozilla's curated collection of root CA certificates for SSL/TLS verification. It exposes two functions: `where()` returns the filesystem path to the bundled `cacert.pem` file, and `contents()` returns its contents as a string. The library handles both modern Python 3.11+ importlib.resources API and older versions, with careful management of context managers and atexit cleanup to support zipimport scenarios. It is a dependency of many popular Python packages (e.g., requests) and is automatically updated daily via a GitHub Actions workflow that fetches the latest Mozilla CA bundle. The codebase is small, well-tested, and demonstrates high craftsmanship in resource management and backward compatibility.
The LLM identified 1 files worth highlighting for reuse:
The core module implements a singleton-like lazy initialization pattern for extracting the bundled cacert.pem file. It uses importlib.resources to locate the file, handling both Python 3.11+ (as_file/files) and older versions (path/read_text). The where() function stores the result in a global variable to avoid re-extraction, and registers an atexit handler to properly close the context manager. This pattern is reusable for any Python package that needs to provide access to bundled data files while supporting zipimport and avoiding resource leaks.