nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix

python3Packages.certifi: Ignore /no-cert-file.crt in NIX_SSL_CERT_FILE

+20 -10
+20 -10
pkgs/development/python-modules/certifi/env.patch
··· 1 1 diff --git a/certifi/core.py b/certifi/core.py 2 - index de02898..3ec9147 100644 2 + index de02898..c033d20 100644 3 3 --- a/certifi/core.py 4 4 +++ b/certifi/core.py 5 - @@ -4,6 +4,7 @@ certifi.py 5 + @@ -4,15 +4,25 @@ certifi.py 6 6 7 7 This module returns the installation location of cacert.pem or its contents. 8 8 """ ··· 10 10 import sys 11 11 12 12 13 - @@ -12,7 +13,7 @@ if sys.version_info >= (3, 11): 13 + +def get_cacert_path_from_environ(): 14 + + path = os.environ.get("NIX_SSL_CERT_FILE", None) 15 + + 16 + + if path == "/no-cert-file.crt": 17 + + return None 18 + + 19 + + return path 20 + + 21 + + 22 + if sys.version_info >= (3, 11): 23 + 14 24 from importlib.resources import as_file, files 15 25 16 26 _CACERT_CTX = None 17 27 - _CACERT_PATH = None 18 - + _CACERT_PATH = os.environ.get("NIX_SSL_CERT_FILE", None) 28 + + _CACERT_PATH = get_cacert_path_from_environ() 19 29 20 30 def where() -> str: 21 31 # This is slightly terrible, but we want to delay extracting the file 22 - @@ -39,14 +40,16 @@ if sys.version_info >= (3, 11): 32 + @@ -39,14 +49,16 @@ if sys.version_info >= (3, 11): 23 33 return _CACERT_PATH 24 34 25 35 def contents() -> str: ··· 44 34 45 35 _CACERT_CTX = None 46 36 - _CACERT_PATH = None 47 - + _CACERT_PATH = os.environ.get("NIX_SSL_CERT_FILE", None) 37 + + _CACERT_PATH = get_cacert_path_from_environ() 48 38 49 39 def where() -> str: 50 40 # This is slightly terrible, but we want to delay extracting the 51 - @@ -74,7 +77,9 @@ elif sys.version_info >= (3, 7): 41 + @@ -74,7 +86,9 @@ elif sys.version_info >= (3, 7): 52 42 return _CACERT_PATH 53 43 54 44 def contents() -> str: ··· 59 49 60 50 else: 61 51 import os 62 - @@ -84,6 +89,8 @@ else: 52 + @@ -84,6 +98,8 @@ else: 63 53 Package = Union[types.ModuleType, str] 64 54 Resource = Union[str, "os.PathLike"] 65 55 66 - + _CACERT_PATH = os.environ.get("NIX_SSL_CERT_FILE", None) 56 + + _CACERT_PATH = get_cacert_path_from_environ() 67 57 + 68 58 # This fallback will work for Python versions prior to 3.7 that lack the 69 59 # importlib.resources module but relies on the existing `where` function 70 60 # so won't address issues with environments like PyOxidizer that don't set 71 - @@ -102,7 +109,14 @@ else: 61 + @@ -102,7 +118,14 @@ else: 72 62 def where() -> str: 73 63 f = os.path.dirname(__file__) 74 64