Skip to content

Commit

Permalink
configure path to CA certificates
Browse files Browse the repository at this point in the history
This will allow opening datasets directly from URLs.

See also https://trac.osgeo.org/gdal/ticket/6732
  • Loading branch information
visr committed Aug 18, 2020
1 parent 8fe5b7d commit 750f47d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ version = "1.1.3"
[deps]
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
GDAL_jll = "a7073274-a066-55f0-b90d-d619367d196c"
MozillaCACerts_jll = "14a3606d-f60d-562e-9121-12d972cd8159"
PROJ_jll = "58948b4f-47e0-5654-a9ad-f609743f8632"

[compat]
Expand Down
4 changes: 4 additions & 0 deletions src/GDAL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module GDAL

using PROJ_jll
using GDAL_jll
using MozillaCACerts_jll
using CEnum

const Ctm = Base.Libc.TmStruct
Expand Down Expand Up @@ -44,6 +45,9 @@ function __init__()
GDAL_DATA[] = joinpath(GDAL_jll.artifact_dir, "share", "gdal")
cplsetconfigoption("GDAL_DATA", GDAL_DATA[])

# set path to CA certificates
cplsetconfigoption("CURL_CA_BUNDLE", cacert)

# set PROJ_LIB location, this overrides setting the environment variable
PROJ_LIB[] = joinpath(PROJ_jll.artifact_dir, "share", "proj")
osrsetprojsearchpaths([PROJ_LIB[]])
Expand Down
7 changes: 7 additions & 0 deletions test/drivers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,10 @@ available_drivers = [
for drivername in available_drivers
@test GDAL.gdalgetdriverbyname(drivername) != C_NULL
end

# errors with BADCERT_NOT_TRUSTED if the CA certificate paths is not properly configured
landsat = "https://landsat-pds.s3.amazonaws.com/L8/139/045/LC81390452014295LGN00/LC81390452014295LGN00_B1.TIF"
ds_landsat = GDAL.gdalopen(string("/vsicurl/", landsat), GDAL.GA_ReadOnly)
GDAL.gdalclose(ds_landsat)
# actually also works without the /vsicurl/ prefix, but takes 50s versus 1s, so let's
# not waste CI time. (it's probably downloading the whole file)

0 comments on commit 750f47d

Please sign in to comment.