Skip to content

Commit 301296d

Browse files
Use system trust store by default (#328)
After internal discussion with @kyteinsky when we tested this nextcloud/app_api#448 - it was found out that the `test-deploy` ExApp from AppAPI "Test Deploy" button action fails in such setups, since the Python library "httpx" ignores system certificates by default. reference: encode/httpx#302 Temporary workaround, until "httpx" will change it's behavior. --------- Signed-off-by: bigcat88 <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 78a6f76 commit 301296d

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

nc_py_api/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Version of nc_py_api."""
22

3-
__version__ = "0.18.1"
3+
__version__ = "0.18.2"

nc_py_api/options.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,22 @@
3333
SSL certificates (a.k.a CA bundle) used to verify the identity of requested hosts. Either **True** (default CA bundle),
3434
a path to an SSL certificate file, or **False** (which will disable verification)."""
3535
str_val = environ.get("NPA_NC_CERT", "True")
36-
NPA_NC_CERT = True
36+
# https://github.com/encode/httpx/issues/302
37+
# when "httpx" will switch to use "truststore" by default - uncomment next line
38+
# NPA_NC_CERT = True
3739
if str_val.lower() in ("false", "0"):
3840
NPA_NC_CERT = False
3941
elif str_val.lower() not in ("true", "1"):
4042
NPA_NC_CERT = str_val
43+
else:
44+
# Temporary workaround, see comment above.
45+
# Use system certificate stores
46+
47+
import ssl
48+
49+
import truststore
50+
51+
NPA_NC_CERT = truststore.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
4152

4253
CHUNKED_UPLOAD_V2 = environ.get("CHUNKED_UPLOAD_V2", True)
4354
"""Option to enable/disable **version 2** chunked upload(better Object Storages support).

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ dependencies = [
4949
"httpx>=0.25.2",
5050
"pydantic>=2.1.1",
5151
"python-dotenv>=1",
52+
"truststore==0.10",
5253
"xmltodict>=0.13",
5354
]
5455
optional-dependencies.app = [

0 commit comments

Comments
 (0)