def get_cacerts_bundle(): """Returns path to a file with CA root certificates bundle.""" global _ca_certs with _ca_certs_lock: if _ca_certs is not None and os.path.exists(_ca_certs): return _ca_certs _ca_certs = zip_package.extract_resource(requests, 'cacert.pem') return _ca_certs
def get_cacerts_bundle(): """Returns path to a file with CA root certificates bundle. Python's ssl module needs a real file on disk, so if code is running from a zip archive, we need to extract the file first. """ global _ca_certs with _ca_certs_lock: if _ca_certs is not None and os.path.exists(_ca_certs): return _ca_certs # Some rogue process clears /tmp and causes cacert.pem to disappear. Extract # to current directory instead. We use our own bundled copy of cacert.pem. _ca_certs = zip_package.extract_resource(utils, 'cacert.pem', temp_dir='.') return _ca_certs