|
| 1 | +# originated from https://git.alpinelinux.org/aports/tree/main/py3-certifi/use-alpine-system-certs.patch |
| 2 | + |
| 3 | +NEVER EVER REMOVE THIS PATCH |
| 4 | +REBASE IT ON TOP OF THE VERSION YOU'RE UPGRADING |
| 5 | + |
| 6 | +This makes py3-certifi use the system certificates provided by Alpine Linux |
| 7 | +instead of the ones provided with py3-certifi instead, this allows us to add |
| 8 | +this package as a dependency for other packages without worries. |
| 9 | + |
| 10 | +This is based on the patch used by Debian |
| 11 | + |
| 12 | +diff --git a/certifi/core.py b/certifi/core.py |
| 13 | +index de02898..9c0235f 100644 |
| 14 | +--- a/certifi/core.py |
| 15 | ++++ b/certifi/core.py |
| 16 | +@@ -6,13 +6,13 @@ This module returns the installation location of cacert.pem or its contents. |
| 17 | + """ |
| 18 | + import sys |
| 19 | + |
| 20 | ++ALPINE_CA_CERTS_PATH = '/etc/ssl/certs/ca-certificates.crt' |
| 21 | + |
| 22 | + if sys.version_info >= (3, 11): |
| 23 | + |
| 24 | + from importlib.resources import as_file, files |
| 25 | + |
| 26 | +- _CACERT_CTX = None |
| 27 | +- _CACERT_PATH = None |
| 28 | ++ _CACERT_PATH = ALPINE_CA_CERTS_PATH |
| 29 | + |
| 30 | + def where() -> str: |
| 31 | + # This is slightly terrible, but we want to delay extracting the file |
| 32 | +@@ -45,8 +45,7 @@ elif sys.version_info >= (3, 7): |
| 33 | + |
| 34 | + from importlib.resources import path as get_path, read_text |
| 35 | + |
| 36 | +- _CACERT_CTX = None |
| 37 | +- _CACERT_PATH = None |
| 38 | ++ _CACERT_PATH = ALPINE_CA_CERTS_PATH |
| 39 | + |
| 40 | + def where() -> str: |
| 41 | + # This is slightly terrible, but we want to delay extracting the |
| 42 | +@@ -71,10 +70,11 @@ elif sys.version_info >= (3, 7): |
| 43 | + _CACERT_CTX = get_path("certifi", "cacert.pem") |
| 44 | + _CACERT_PATH = str(_CACERT_CTX.__enter__()) |
| 45 | + |
| 46 | +- return _CACERT_PATH |
| 47 | ++ return ALPINE_CA_CERTS_PATH |
| 48 | + |
| 49 | + def contents() -> str: |
| 50 | +- return read_text("certifi", "cacert.pem", encoding="ascii") |
| 51 | ++ with open(where(), "r", encoding="ascii") as data: |
| 52 | ++ return data.read() |
| 53 | + |
| 54 | + else: |
| 55 | + import os |
| 56 | +@@ -100,9 +100,7 @@ else: |
| 57 | + # If we don't have importlib.resources, then we will just do the old logic |
| 58 | + # of assuming we're on the filesystem and munge the path directly. |
| 59 | + def where() -> str: |
| 60 | +- f = os.path.dirname(__file__) |
| 61 | +- |
| 62 | +- return os.path.join(f, "cacert.pem") |
| 63 | +- |
| 64 | ++ return ALPINE_CA_CERTS_PATH |
| 65 | + def contents() -> str: |
| 66 | +- return read_text("certifi", "cacert.pem", encoding="ascii") |
| 67 | ++ with open(where(), "r", encoding="ascii") as data: |
| 68 | ++ return data.read() |
0 commit comments