如何在第三方python库中禁用SSL验证?

时间:2018-02-21 15:39:58

标签: python ssl ssl-certificate verify

我正在使用python库OSMnx,它向nomatim.openstreetmap.org发出请求,以生成并加载随后用于创建网络的地图。但是,当我尝试通过VPN或办公室运行时,我得到了这个:

File "C:\ProgramData\Anaconda3\lib\site-packages\flask\app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "C:\ProgramData\Anaconda3\lib\site-packages\flask\app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\ProgramData\Anaconda3\lib\site-packages\flask\app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\ProgramData\Anaconda3\lib\site-packages\flask\_compat.py", line 33, in reraise
raise value
File "C:\ProgramData\Anaconda3\lib\site-packages\flask\app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "C:\ProgramData\Anaconda3\lib\site-packages\flask\app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\ProgramData\Anaconda3\lib\site-packages\dash\dash.py", line 551, in dispatch
return self.callback_map[target_id]['callback'](*args)
File "C:\ProgramData\Anaconda3\lib\site-packages\dash\dash.py", line 508, in add_context
output_value = func(*args, **kwargs)
File "OSMnxTest.py", line 125, in createNetwork
gdf = ox.gdf_from_place(location)
File "C:\ProgramData\Anaconda3\lib\site-packages\osmnx\core.py", line 414, in gdf_from_place
data = osm_polygon_download(query, limit=which_result)
File "C:\ProgramData\Anaconda3\lib\site-packages\osmnx\core.py", line 382, in osm_polygon_download
response_json = nominatim_request(params=params, timeout=30)
File "C:\ProgramData\Anaconda3\lib\site-packages\osmnx\core.py", line 238, in nominatim_request
response = requests.get(url, params=params, timeout=timeout, headers=get_http_headers())
File "C:\ProgramData\Anaconda3\lib\site-packages\requests\api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\requests\api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\requests\sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\requests\sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\requests\adapters.py", line 506, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='nominatim.openstreetmap.org', port=443): Max retries exceeded with url: /search?format=json&limit=1&dedupe=0&polygon_geojson=1&q=mclean%2Cva%2Cusa (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),))

我想在我正在创建的脚本中实现修复,并且我知道禁用证书的对等验证的危险,所以我只想为我发送的所有查询设置ssl_verify参数为false通过这个图书馆。我怎么能这样做?

0 个答案:

没有答案