metno / NWPdocs

Description of the numerical weather prediction products at MET Norway
GNU General Public License v3.0
14 stars 4 forks source link

Error:curl error: Problem with the SSL CA cert (path? access rights?) #25

Closed paapu88 closed 1 year ago

paapu88 commented 1 year ago

Was trying to run copy pasted example from metno examples:

import xarray
import numpy as np

opendap_url = "https://thredds.met.no/thredds/dodsC/aromearcticlatest/"+\
              "archive/arome_arctic_det_2_5km_latest.nc"
#Ask for time=0 to make the calculation smaller, height0=0 to remove the 4th dimension
ds = xarray.open_dataset(opendap_url).isel(time=0,height0=0)

# Formula to calculate pressure from hybrid: p(n,k,j,i) = ap(k) + b(k)*ps(n,j,i)"
ap = ds.ap
b = ds.b
surface_pressure = ds.surface_air_pressure

# Note that k = 0 is top of atmosphere (ToA), and k = 64 is surface
pressure_at_k = (ap + (b*surface_pressure))
temperature_at_k = ds.air_temperature_ml
R = 287.058
g = 9.81

height_at_k = xarray.full_like(pressure_at_k, fill_value=0)

max_k = len(height_at_k.hybrid) -1
# Compute the height of the lowest model level
height_at_k.values[max_k,:,:] = (R*temperature_at_k.isel(hybrid=max_k))/g
height_at_k.values[max_k,:,:] *= np.log(surface_pressure / (pressure_at_k.isel(hybrid = max_k)))

# Loop over the rest of the model levels
for hybrid in range(max_k - 1,-1,-1):
    height_at_k.values[hybrid,:,:] = (R*temperature_at_k.isel(hybrid=hybrid))/g
    height_at_k.values[hybrid,:,:] *= np.log((pressure_at_k.isel(hybrid = hybrid + 1)) / \
                                             (pressure_at_k.isel(hybrid = hybrid)))
    height_at_k.values[hybrid,:,:] += height_at_k.isel(hybrid=hybrid + 1)

but got error Error:curl error: Problem with the SSL CA cert (path? access rights?)

google says this is server side error due to outdated SSL certificate(s) for cURL installed on the server.

terveisin, Markus

johtoblan commented 1 year ago

Hi Markus!

We believe this error to be in the netcdf4 dependency for xarray. We have a found a possible solution to be to create a file in your home directory called .ncrcand add this line: HTTP.SSL.CAINFO=/etc/ssl/certs/ca-certificates.crt

Please retry this and let me know if this does not solve the issue

cskarby commented 1 year ago

Hello Markus!

Please check Johannes reply above for a suggest fix!

I just wanted to add that the certificates on thredds.met.no are configured according to recommended practice - the scan results are available on https://www.ssllabs.com/ssltest/analyze.html?d=thredds.met.no&hideResults=on

image

image

As the server is passing the SSL test with no warnings in the section "Certification Paths", it seems to be a problem on the client side. Please try the proposed workaround, or upgrade your software libraries. It may have been fixed in more recent releases of NetCDF.

paapu88 commented 1 year ago

I tested with xarray version xarray==2023.1.0 and now it works.

So it was my problem had nothing to do with your site, sorry for a false alarm.

My guess is that my version of xarray or some other package was too old.