|
|
04eeea |
From 09c983fdeabe3fa0b90b73f32ddf84a61e498e09 Mon Sep 17 00:00:00 2001
|
|
|
04eeea |
From: Karolina Surma <ksurma@redhat.com>
|
|
|
04eeea |
Date: Tue, 15 Nov 2022 09:22:46 +0100
|
|
|
04eeea |
Subject: [PATCH] Dummy certifi patch
|
|
|
04eeea |
|
|
|
04eeea |
---
|
|
|
04eeea |
src/pip/_vendor/certifi/core.py | 105 ++------------------------------
|
|
|
04eeea |
1 file changed, 6 insertions(+), 99 deletions(-)
|
|
|
04eeea |
|
|
|
04eeea |
diff --git a/src/pip/_vendor/certifi/core.py b/src/pip/_vendor/certifi/core.py
|
|
|
04eeea |
index c3e5466..eb297f7 100644
|
|
|
04eeea |
--- a/src/pip/_vendor/certifi/core.py
|
|
|
04eeea |
+++ b/src/pip/_vendor/certifi/core.py
|
|
|
04eeea |
@@ -4,105 +4,12 @@ certifi.py
|
|
|
04eeea |
|
|
|
04eeea |
This module returns the installation location of cacert.pem or its contents.
|
|
|
04eeea |
"""
|
|
|
04eeea |
-import sys
|
|
|
04eeea |
|
|
|
04eeea |
+# The RPM-packaged certifi always uses the system certificates
|
|
|
04eeea |
+def where() -> str:
|
|
|
04eeea |
+ return '/etc/pki/tls/certs/ca-bundle.crt'
|
|
|
04eeea |
|
|
|
04eeea |
-if sys.version_info >= (3, 11):
|
|
|
04eeea |
+def contents() -> str:
|
|
|
04eeea |
+ with open(where(), encoding='utf=8') as data:
|
|
|
04eeea |
+ return data.read()
|
|
|
04eeea |
|
|
|
04eeea |
- from importlib.resources import as_file, files
|
|
|
04eeea |
-
|
|
|
04eeea |
- _CACERT_CTX = None
|
|
|
04eeea |
- _CACERT_PATH = None
|
|
|
04eeea |
-
|
|
|
04eeea |
- def where() -> str:
|
|
|
04eeea |
- # This is slightly terrible, but we want to delay extracting the file
|
|
|
04eeea |
- # in cases where we're inside of a zipimport situation until someone
|
|
|
04eeea |
- # actually calls where(), but we don't want to re-extract the file
|
|
|
04eeea |
- # on every call of where(), so we'll do it once then store it in a
|
|
|
04eeea |
- # global variable.
|
|
|
04eeea |
- global _CACERT_CTX
|
|
|
04eeea |
- global _CACERT_PATH
|
|
|
04eeea |
- if _CACERT_PATH is None:
|
|
|
04eeea |
- # This is slightly janky, the importlib.resources API wants you to
|
|
|
04eeea |
- # manage the cleanup of this file, so it doesn't actually return a
|
|
|
04eeea |
- # path, it returns a context manager that will give you the path
|
|
|
04eeea |
- # when you enter it and will do any cleanup when you leave it. In
|
|
|
04eeea |
- # the common case of not needing a temporary file, it will just
|
|
|
04eeea |
- # return the file system location and the __exit__() is a no-op.
|
|
|
04eeea |
- #
|
|
|
04eeea |
- # We also have to hold onto the actual context manager, because
|
|
|
04eeea |
- # it will do the cleanup whenever it gets garbage collected, so
|
|
|
04eeea |
- # we will also store that at the global level as well.
|
|
|
04eeea |
- _CACERT_CTX = as_file(files("pip._vendor.certifi").joinpath("cacert.pem"))
|
|
|
04eeea |
- _CACERT_PATH = str(_CACERT_CTX.__enter__())
|
|
|
04eeea |
-
|
|
|
04eeea |
- return _CACERT_PATH
|
|
|
04eeea |
-
|
|
|
04eeea |
- def contents() -> str:
|
|
|
04eeea |
- return files("pip._vendor.certifi").joinpath("cacert.pem").read_text(encoding="ascii")
|
|
|
04eeea |
-
|
|
|
04eeea |
-elif sys.version_info >= (3, 7):
|
|
|
04eeea |
-
|
|
|
04eeea |
- from importlib.resources import path as get_path, read_text
|
|
|
04eeea |
-
|
|
|
04eeea |
- _CACERT_CTX = None
|
|
|
04eeea |
- _CACERT_PATH = None
|
|
|
04eeea |
-
|
|
|
04eeea |
- def where() -> str:
|
|
|
04eeea |
- # This is slightly terrible, but we want to delay extracting the
|
|
|
04eeea |
- # file in cases where we're inside of a zipimport situation until
|
|
|
04eeea |
- # someone actually calls where(), but we don't want to re-extract
|
|
|
04eeea |
- # the file on every call of where(), so we'll do it once then store
|
|
|
04eeea |
- # it in a global variable.
|
|
|
04eeea |
- global _CACERT_CTX
|
|
|
04eeea |
- global _CACERT_PATH
|
|
|
04eeea |
- if _CACERT_PATH is None:
|
|
|
04eeea |
- # This is slightly janky, the importlib.resources API wants you
|
|
|
04eeea |
- # to manage the cleanup of this file, so it doesn't actually
|
|
|
04eeea |
- # return a path, it returns a context manager that will give
|
|
|
04eeea |
- # you the path when you enter it and will do any cleanup when
|
|
|
04eeea |
- # you leave it. In the common case of not needing a temporary
|
|
|
04eeea |
- # file, it will just return the file system location and the
|
|
|
04eeea |
- # __exit__() is a no-op.
|
|
|
04eeea |
- #
|
|
|
04eeea |
- # We also have to hold onto the actual context manager, because
|
|
|
04eeea |
- # it will do the cleanup whenever it gets garbage collected, so
|
|
|
04eeea |
- # we will also store that at the global level as well.
|
|
|
04eeea |
- _CACERT_CTX = get_path("pip._vendor.certifi", "cacert.pem")
|
|
|
04eeea |
- _CACERT_PATH = str(_CACERT_CTX.__enter__())
|
|
|
04eeea |
-
|
|
|
04eeea |
- return _CACERT_PATH
|
|
|
04eeea |
-
|
|
|
04eeea |
- def contents() -> str:
|
|
|
04eeea |
- return read_text("pip._vendor.certifi", "cacert.pem", encoding="ascii")
|
|
|
04eeea |
-
|
|
|
04eeea |
-else:
|
|
|
04eeea |
- import os
|
|
|
04eeea |
- import types
|
|
|
04eeea |
- from typing import Union
|
|
|
04eeea |
-
|
|
|
04eeea |
- Package = Union[types.ModuleType, str]
|
|
|
04eeea |
- Resource = Union[str, "os.PathLike"]
|
|
|
04eeea |
-
|
|
|
04eeea |
- # This fallback will work for Python versions prior to 3.7 that lack the
|
|
|
04eeea |
- # importlib.resources module but relies on the existing `where` function
|
|
|
04eeea |
- # so won't address issues with environments like PyOxidizer that don't set
|
|
|
04eeea |
- # __file__ on modules.
|
|
|
04eeea |
- def read_text(
|
|
|
04eeea |
- package: Package,
|
|
|
04eeea |
- resource: Resource,
|
|
|
04eeea |
- encoding: str = 'utf-8',
|
|
|
04eeea |
- errors: str = 'strict'
|
|
|
04eeea |
- ) -> str:
|
|
|
04eeea |
- with open(where(), encoding=encoding) as data:
|
|
|
04eeea |
- return data.read()
|
|
|
04eeea |
-
|
|
|
04eeea |
- # If we don't have importlib.resources, then we will just do the old logic
|
|
|
04eeea |
- # of assuming we're on the filesystem and munge the path directly.
|
|
|
04eeea |
- def where() -> str:
|
|
|
04eeea |
- f = os.path.dirname(__file__)
|
|
|
04eeea |
-
|
|
|
04eeea |
- return os.path.join(f, "cacert.pem")
|
|
|
04eeea |
-
|
|
|
04eeea |
- def contents() -> str:
|
|
|
04eeea |
- return read_text("pip._vendor.certifi", "cacert.pem", encoding="ascii")
|
|
|
04eeea |
--
|
|
|
04eeea |
2.37.3
|
|
|
04eeea |
|