OSGeo / PROJ

PROJ - Cartographic Projections and Coordinate Transformations Library
https://proj.org
Other
1.74k stars 785 forks source link

PROJ_CURL_CA_BUNDLE global env var not being picked up #3977

Open brynpickering opened 11 months ago

brynpickering commented 11 months ago

I only have experience with using PROJ via pyproj, but the issue I raised there (https://github.com/pyproj4/pyproj/issues/1233) seems more appropriate here. Namely, PROJ seems to not be picking up my globally set environment variables when it receives an empty string to proj_context_set_ca_bundle_path.

Example of problem

using pyproj:

from pyproj.network import set_ca_bundle_path, set_network_enabled
from pyproj.transformer import Transformer

set_network_enabled(True)
set_ca_bundle_path()
t = Transformer.from_crs("epsg:27700", "epsg:4326")
print(t.transform(0, 0, None, errcheck=True))

I get the error: transform error: Network error when accessing a remote resource: (Internal Proj Error: Cannot open https://cdn.proj.org/uk_os_OSTN15_NTv2_OSGBtoETRS.tif: SSL certificate problem: unable to get local issuer certificate)

Even though I have both PROJ_CURL_CA_BUNDLE and CURL_CA_BUNDLE set globally on my machine.

Passing the path to my CA bundle explicitly to set_ca_bundle_path (and therefore proj_context_set_ca_bundle_path) works as expected.

Problem description

I have a limited understanding of C, but since it is strongly typed I assume proj_context_set_ca_bundle_path has to receive a string when called. pyproj goes with an empty string to invoke a search through the available environment variables in PROJ and I would expect this to land on the path to my CA bundle.

Environment Information

Installation method

rouault commented 11 months ago

PROJ seems to not be picking up my globally set environment variables when it receives an empty string to proj_context_set_ca_bundle_path.

yes this is intended. If the user calls proj_context_set_ca_bundle_path(), this overrides whatever was set through the environment variables. Probably the fix should be on pyproj4 side to not call proj_context_set_ca_bundle_path() if they are set.

brynpickering commented 11 months ago

OK, I just tried removing the call to proj_context_set_ca_bundle_path in pyproj initialisation and the SSL certificate problem persists. Does this suggest that PROJ isn't finding the environment variables of its own accord?