我在Python后端脚本中使用pydap Python包装器来访问数据访问协议(DAP),以访问NASA GES DISC数据(Earthdata)档案(NASA Aura OMI)中的一些实时大气数据集气溶胶光学深度数据-https://acdisc.gsfc.nasa.gov/data/Aura_OMI_Level3/OMAEROe.003/2019/)。
pydap文档中描述的专门访问Earthdata(https://www.pydap.org/en/latest/client.html#urs-nasa-earthdata)的过程为我产生了SSL证书错误。
In [1] from pydap.client import open_url
In [2] from pydap.cas.urs import setup_session
In [3] dataset_url = 'https://acdisc.gsfc.nasa.gov/data/Aura_OMI_Level3/OMAEROe.003/2019/'
In [4] session = setup_session(openid, password, check_url=dataset_url)
In [5] remote_file = '{}/OMI-Aura_L3-OMAEROe_2019m0923_v003-2019m0925t032200.he5'.format(dataset_url)
In [6] remote_file
Out [6] 'https://acdisc.gsfc.nasa.gov/data/Aura_OMI_Level3/OMAEROe.003/2019/OMI-Aura_L3-OMAEROe_2019m0923_v003-2019m0925t032200.he5'
In [7] dataset = open_url(remote_file, session=session)
/path/to/myvenv/lib/python3.7/site-packages/pydap/client.py in open_url(url, application, session, output_grid, timeout)
65 """
66 dataset = DAPHandler(url, application, session, output_grid,
---> 67 timeout).dataset
68
69 # attach server-side functions
/path/to/myvenv/lib/python3.7/site-packages/pydap/handlers/dap.py in __init__(self, url, application, session, output_grid, timeout)
51
52 ddsurl = urlunsplit((scheme, netloc, path + '.dds', query, fragment))
---> 53 r = GET(ddsurl, application, session, timeout=timeout)
54 raise_for_status(r)
55 if not r.charset:
/path/to/myvenv/lib/python3.7/site-packages/pydap/net.py in GET(url, application, session, timeout)
25
26 return follow_redirect(url, application=application, session=session,
---> 27 timeout=timeout)
28
29
/path/to/myvenv/lib/python3.7/site-packages/pydap/net.py in follow_redirect(url, application, session, timeout)
49
50 req = create_request(url, session=session, timeout=timeout)
---> 51 return req.get_response(application)
52
53
/path/to/myvenv/lib/python3.7/site-packages/webob/request.py in send(self, application, catch_exc_info)
1312 else:
1313 status, headers, app_iter = self.call_application(
-> 1314 application, catch_exc_info=False)
1315 return self.ResponseClass(
1316 status=status, headerlist=list(headers), app_iter=app_iter)
/path/to/myvenv/lib/python3.7/site-packages/webob/request.py in call_application(self, application, catch_exc_info)
1276 captured[:] = [status, headers, exc_info]
1277 return output.append
-> 1278 app_iter = application(self.environ, start_response)
1279 if output or not captured:
1280 try:
/path/to/myvenv/lib/python3.7/site-packages/webob/client.py in __call__(self, environ, start_response)
91 try:
92 conn.request(environ['REQUEST_METHOD'],
---> 93 path, body, headers)
94 res = conn.getresponse()
95 except socket.timeout:
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py in request(self, method, url, body, headers, encode_chunked)
1242 encode_chunked=False):
1243 """Send a complete request to the server."""
-> 1244 self._send_request(method, url, body, headers, encode_chunked)
1245
1246 def _send_request(self, method, url, body, headers, encode_chunked):
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py in _send_request(self, method, url, body, headers, encode_chunked)
1288 # default charset of iso-8859-1.
1289 body = _encode(body, 'body')
-> 1290 self.endheaders(body, encode_chunked=encode_chunked)
1291
1292 def getresponse(self):
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py in endheaders(self, message_body, encode_chunked)
1237 else:
1238 raise CannotSendHeader()
-> 1239 self._send_output(message_body, encode_chunked=encode_chunked)
1240
1241 def request(self, method, url, body=None, headers={}, *,
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py in _send_output(self, message_body, encode_chunked)
1024 msg = b"\r\n".join(self._buffer)
1025 del self._buffer[:]
-> 1026 self.send(msg)
1027
1028 if message_body is not None:
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py in send(self, data)
964 if self.sock is None:
965 if self.auto_open:
--> 966 self.connect()
967 else:
968 raise NotConnected()
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py in connect(self)
1412
1413 self.sock = self._context.wrap_socket(self.sock,
-> 1414 server_hostname=server_hostname)
1415
1416 __all__.append("HTTPSConnection")
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session)
421 server_hostname=server_hostname,
422 context=self,
--> 423 session=session
424 )
425
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py in _create(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session)
868 # non-blocking
869 raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets")
--> 870 self.do_handshake()
871 except (OSError, ValueError):
872 self.close()
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py in do_handshake(self, block)
1137 if timeout == 0.0 and block:
1138 self.settimeout(None)
-> 1139 self._sslobj.do_handshake()
1140 finally:
1141 self.settimeout(timeout)
SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)
我认为我可以通过在创建verify
对象时将False
选项设置为session
来解决此问题,但是实际上这没有什么区别,并且我得到相同的错误。 / p>