2

I'm attempting to get the pixel value of a raster that stored in an S3 bucket via a script that's using Flask and is hosted on Google's App Engine. If I run the script on my local machine, everything works fine. When I attempt to deploy the script to GAE, it deploys fine, but the web app does not work. I believe it has something to do with the AWS access keys. I have them in my app.yaml as such:

env_variables: 
    AWS_ACCESS_KEY_ID: 'my-key-id'
    AWS_SECRET_ACCESS_KEY: 'my-secret-key-id'
    

I've also tried setting the variables in the actual python script using:

os.environ['AWS_SECRET_ACCESS_KEY'] = secret_access_key
os.environ['AWS_ACCESS_KEY_ID'] = access_key

the error I'm getting is:

Traceback (most recent call last): File "rasterio/_base.pyx", line 216,
in rasterio._base.DatasetBase.__init__ File "rasterio/_shim.pyx", line 67,
in rasterio._shim.open_dataset File "rasterio/_err.pyx", line 205,
in rasterio._err.exc_wrap_pointer rasterio._err.CPLE_HttpResponseError: 
CURL error: error setting certificate verify locations: CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none

Can anyone see why this error is being thrown or has anyone used rasterio in GAE before?

4
  • I don't use GAE, so can't be any more specific than it sounds like you may need to figure out where the CA certs are in GAE, and tell the curl library where they are github.com/mapbox/rasterio/issues/1737#issuecomment-524001890 github.com/mapbox/rasterio#ssl-certs
    – user2856
    Commented Aug 21, 2020 at 1:38
  • do you know if CA certs are "Certificate Authority certs" or does that mean something else?
    – JWB
    Commented Aug 21, 2020 at 2:28
  • 1
    Yes Certificate Authority (CA) certificates
    – user2856
    Commented Aug 21, 2020 at 3:05
  • @user2856 I tried that in the python code and tried adding it as an env_variable in the .yaml and the same error returns. I also tried another path that i had found online of "/etc/ssl/certs/ca-certificates.crt" with no avail
    – JWB
    Commented Aug 21, 2020 at 14:26

1 Answer 1

3

rasterio 1.1.8 now depends on certifi:

- If the certifi package can be imported, its certificate store location will be passed to GDAL during import of rasterio._env unless CURL_CA_BUNDLE is already set (#2009).

So updating rasterio should fix your CURL error: error setting certificate problem.

If you can't update, but you can install certifi, you could try something like:

rasterio.Env(CURL_CA_BUNDLE=certifi.where())

Or from a comment by StefanBrand_EOX:

os.environ.setdefault("CURL_CA_BUNDLE", certifi.where())
4
  • Thank you so much for this!
    – JWB
    Commented Oct 22, 2020 at 4:18
  • Credit to @snowman who proposed #2009
    – user2856
    Commented Oct 22, 2020 at 4:31
  • I have installed rasterio 1.1.8 and cannot get rid of this error, unfortunately. I have GDAL 3.0.2 on Ubuntu 20.04. Ok, sorry, this is not GAE, of course. Commented Jan 13, 2021 at 10:00
  • This actually works for me: os.environ.setdefault("CURL_CA_BUNDLE", certifi.where()) Commented Jan 13, 2021 at 10:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.