SSLError: HTTPSConnectionPool with "paddleocr" - python

I'm actually trying to use "paddleocr" with python
I use a conda environnement
i followed the guide on their github : https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.5/doc/doc_en/quickstart_en.md
But when i try to execute this command :
(paddle_env) C:\Windows\system32>paddleocr --image_dir "path\image" --use_angle_cls true --lang en --use_gpu false
i get this error :
download https://paddleocr.bj.bcebos.com/PP-OCRv3/english/en_PP-OCRv3_det_infer.tar to C:\Users\PD/.paddleocr/whl\det\en\en_PP-OCRv3_det_infer\en_PP-OCRv3_det_infer.tar
Traceback (most recent call last):
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\urllib3\connectionpool.py", line 1042, in _validate_conn
conn.connect()
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\urllib3\connection.py", line 414, in connect
self.sock = ssl_wrap_socket(
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\urllib3\util\ssl_.py", line 449, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\urllib3\util\ssl_.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\ssl.py", line 1040, in _create
self.do_handshake()
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1131)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\requests\adapters.py", line 489, in send
resp = conn.urlopen(
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen
retries = retries.increment(
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\urllib3\util\retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='paddleocr.bj.bcebos.com', port=443): Max retries exceeded with url: /PP-OCRv3/english/en_PP-OCRv3_det_infer.tar (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1131)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\PD\anaconda3\envs\paddle_env\Scripts\paddleocr.exe\__main__.py", line 7, in <module>
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\paddleocr\paddleocr.py", line 571, in main
engine = PaddleOCR(**(args.__dict__))
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\paddleocr\paddleocr.py", line 420, in __init__
maybe_download(params.det_model_dir, det_url)
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\paddleocr\ppocr\utils\network.py", line 55, in maybe_download
download_with_progressbar(url, tmp_path)
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\paddleocr\ppocr\utils\network.py", line 26, in download_with_progressbar
response = requests.get(url, stream=True)
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\requests\api.py", line 73, in get
return request("get", url, params=params, **kwargs)
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\requests\api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\requests\sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\requests\sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
File "C:\Users\PD\anaconda3\envs\paddle_env\lib\site-packages\requests\adapters.py", line 563, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='paddleocr.bj.bcebos.com', port=443): Max retries exceeded with url: /PP-OCRv3/english/en_PP-OCRv3_det_infer.tar (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1131)')))
paddleocr version : 2.5.0.3
python version : 3.8.13

It seems that you can not access the downlink provided by PaddleOCR, you can try to download the models on its mainpage, set rec_model_dir and det_model_dir mannually. (link)
demo image

Related

How can you disable SSL verification in urlib3?

I am getting this error:
Traceback (most recent call last):
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/urllib3/connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/urllib3/connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/urllib3/connectionpool.py", line 1042, in _validate_conn
conn.connect()
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/urllib3/connection.py", line 416, in connect
self.sock = ssl_wrap_socket(
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/urllib3/util/ssl_.py", line 449, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/urllib3/util/ssl_.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "/usr/lib/python3.8/ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "/usr/lib/python3.8/ssl.py", line 1040, in _create
self.do_handshake()
File "/usr/lib/python3.8/ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1131)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/requests/adapters.py", line 489, in send
resp = conn.urlopen(
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/urllib3/connectionpool.py", line 787, in urlopen
retries = retries.increment(
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/urllib3/util/retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www.example.com', port=8080): Max retries exceeded with url: /geoserver/ows?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=qazqoinau_test%3A%D0%93%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0%20%D0%A0%D0%B5%D1%81%D0%BF%D1%83%D0%B1%D0%BB%D0%B8%D0%BA%D0%B8%20%D0%9A%D0%B0%D0%B7%D0%B0%D1%85%D1%81%D1%82%D0%B0%D0%BD&STYLES=qazqoinau_test%3Alayers_border_RK&SRS=EPSG%3A3857&CRS=EPSG%3A3857&TILED=true&access_token=JNkYj4bIfuWQbQu06AAF2MUxc9banx&WIDTH=512&HEIGHT=512&BBOX=2504688.542848654%2C2504688.542848654%2C5009377.08569731%2C5009377.08569731 (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1131)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/requests/api.py", line 73, in get
return request("get", url, params=params, **kwargs)
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/requests/api.py", line 59, in request
return session.request(method=method, url=url,verify=False,**kwargs)
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/requests/sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/requests/sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
File "/home/adminko/.geonodevirtaulenvs/geonode/lib/python3.8/site-packages/requests/adapters.py", line 563, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='www.example.com', port=8080): Max retries exceeded with url: /geoserver/ows?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=qazqoinau_test%3A%D0%93%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0%20%D0%A0%D0%B5%D1%81%D0%BF%D1%83%D0%B1%D0%BB%D0%B8%D0%BA%D0%B8%20%D0%9A%D0%B0%D0%B7%D0%B0%D1%85%D1%81%D1%82%D0%B0%D0%BD&STYLES=qazqoinau_test%3Alayers_border_RK&SRS=EPSG%3A3857&CRS=EPSG%3A3857&TILED=true&access_token=JNkYj4bIfuWQbQu06AAF2MUxc9banx&WIDTH=512&HEIGHT=512&BBOX=2504688.542848654%2C2504688.542848654%2C5009377.08569731%2C5009377.08569731 (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1131)')))
How can I disable checking this SSL verification or how can I handle this error (consequences after changing )? I am ready to change package code to handle this error. Everything was working when I was using HTTP connection.
I have already changed request.get(verify = False)
my code
import requests
requests.get('https://www.example.com:8080/geoserver/ows?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=qazqoinau_test%3A%D0%93%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0%20%D0%A0%D0%B5%D1%81%D0%BF%D1%83%D0%B1%D0%BB%D0%B8%D0%BA%D0%B8%20%D0%9A%D0%B0%D0%B7%D0%B0%D1%85%D1%81%D1%82%D0%B0%D0%BD&STYLES=qazqoinau_test%3Alayers_border_RK&SRS=EPSG%3A3857&CRS=EPSG%3A3857&TILED=true&access_token=JNkYj4bIfuWQbQu06AAF2MUxc9banx&WIDTH=512&HEIGHT=512&BBOX=2504688.542848654%2C2504688.542848654%2C5009377.08569731%2C5009377.08569731')

Acumos model onboarding python CLI

I'm trying to onboard a simple python model from CLI as shown in the related tutorial.
After providing the onboarding token (user:api-token) I'm getting the error below.
The Acumos platform has been deployed using the AIO tools using prep-deploy process.
I was able to dump the same model and onboard using the web UI.
Traceback (most recent call last):
File "/home/gprato/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 677, in urlopen
chunked=chunked,
File "/home/gprato/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 381, in _make_request
self._validate_conn(conn)
File "/home/gprato/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 978, in _validate_conn
conn.connect()
File "/home/gprato/.local/lib/python3.6/site-packages/urllib3/connection.py", line 371, in connect
ssl_context=context,
File "/home/gprato/.local/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 384, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/usr/lib/python3.6/ssl.py", line 407, in wrap_socket
_context=self, _session=session)
File "/usr/lib/python3.6/ssl.py", line 817, in __init__
self.do_handshake()
File "/usr/lib/python3.6/ssl.py", line 1077, in do_handshake
self._sslobj.do_handshake()
File "/usr/lib/python3.6/ssl.py", line 689, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/gprato/.local/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/home/gprato/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 727, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File "/home/gprato/.local/lib/python3.6/site-packages/urllib3/util/retry.py", line 439, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='***', port=443): Max retries exceeded with url: /onboarding-app/v2/models (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "simple_example.py", line 16, in <module>
session.push(model, 'example-2')
File "/home/gprato/.local/lib/python3.6/site-packages/acumos/session.py", line 103, in push
_push_model(dump_dir, self.push_api, self.auth_api, options, extra_headers=extra_headers)
File "/home/gprato/.local/lib/python3.6/site-packages/acumos/session.py", line 172, in _push_model
_post_model(files, push_api, auth_api, tries, max_tries, extra_headers, options)
File "/home/gprato/.local/lib/python3.6/site-packages/acumos/session.py", line 192, in _post_model
resp = requests.post(push_api, files=files, headers=headers)
File "/home/gprato/.local/lib/python3.6/site-packages/requests/api.py", line 119, in post
return request('post', url, data=data, json=json, **kwargs)
File "/home/gprato/.local/lib/python3.6/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/home/gprato/.local/lib/python3.6/site-packages/requests/sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "/home/gprato/.local/lib/python3.6/site-packages/requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "/home/gprato/.local/lib/python3.6/site-packages/requests/adapters.py", line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='***', port=443): Max retries exceeded with url: /onboarding-app/v2/models (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),))
UPDATE
I've solved by adding the following line into the python script:
os.environ['CURL_CA_BUNDLE'] = ""
In addition to that I also had to change the push url ("acumos/onboarding-app/v2/models") as it was wrongly reported in the acumos python client library ("acumos/onboarding-app/v2/push").
I recomend you to add the following in your python script
os.environ['CURL_CA_BUNDLE'] = ""
it will skip the certificate verification

squeezenet1.1.caffemodel" is not existing file

I have installed all the required steps for openvino. but while running the demos, to make sure that every thing is working fine , I am recieving this error : The "C:\Users\OGNGHAFF\Documents\Intel\OpenVINO\openvino_models\models\public\squeezenet1.1/squeezenet1.1.caffemodel" is not existing file
I couldn't find any solution.
cd C:\Program Files (x86)\IntelSWTools\openvino\bin\
setupvars.bat
This is working fine. Then I am running initilazation:
cd C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\model_optimizer\install_prerequisites
install_prerequisites.bat
This is also working fine, but then when I want to run demo :
cd C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\demo\
demo_squeezenet_download_convert_run.bat
I am recieving this error :
**Download public squeezenet1.1 model
python "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\open_model_zoo\tools\downloader\downloader.py" --name "squeezenet1.1" --output_dir "C:\Users\OGNGHAFF\Documents\Intel\OpenVINO\openvino_models\models" --cache_dir "C:\Users\OGNGHAFF\Documents\Intel\OpenVINO\openvino_models\cache"
################|| Downloading models ||################
========== Downloading C:\Users\OGNGHAFF\Documents\Intel\OpenVINO\openvino_models\models\public\squeezenet1.1\squeezenet1.1.prototxt
Traceback (most recent call last):
File "C:\Users\OGNGHAFF\AppData\Roaming\Python\Python36\site-packages\urllib3\connectionpool.py", line 601, in urlopen
chunked=chunked)
File "C:\Users\OGNGHAFF\AppData\Roaming\Python\Python36\site-packages\urllib3\connectionpool.py", line 346, in _make_request
self._validate_conn(conn)
File "C:\Users\OGNGHAFF\AppData\Roaming\Python\Python36\site-packages\urllib3\connectionpool.py", line 850, in _validate_conn
conn.connect()
File "C:\Users\OGNGHAFF\AppData\Roaming\Python\Python36\site-packages\urllib3\connection.py", line 326, in connect
ssl_context=context)
File "C:\Users\OGNGHAFF\AppData\Roaming\Python\Python36\site-packages\urllib3\util\ssl_.py", line 329, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\OGNGHAFF\AppData\Local\Programs\Python\Python36\lib\ssl.py", line 407, in wrap_socket
_context=self, _session=session)
File "C:\Users\OGNGHAFF\AppData\Local\Programs\Python\Python36\lib\ssl.py", line 814, in __init__
self.do_handshake()
File "C:\Users\OGNGHAFF\AppData\Local\Programs\Python\Python36\lib\ssl.py", line 1068, in do_handshake
self._sslobj.do_handshake()
File "C:\Users\OGNGHAFF\AppData\Local\Programs\Python\Python36\lib\ssl.py", line 689, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\OGNGHAFF\AppData\Roaming\Python\Python36\site-packages\requests\adapters.py", line 440, in send
timeout=timeout
File "C:\Users\OGNGHAFF\AppData\Roaming\Python\Python36\site-packages\urllib3\connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:\Users\OGNGHAFF\AppData\Roaming\Python\Python36\site-packages\urllib3\util\retry.py", line 388, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='raw.githubusercontent.com', port=443): Max retries exceeded with url: /DeepScale/SqueezeNet/a47b6f13d30985279789d08053d37013d67d131b/SqueezeNet_v1.1/deploy.prototxt (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\open_model_zoo\tools\downloader\downloader.py", line 71, in try_download
chunk_iterable = start_download()
File "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\open_model_zoo\tools\downloader\downloader.py", line 261, in <lambda>
lambda: model_file.source.start_download(session, CHUNK_SIZE)):
File "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\open_model_zoo\tools\downloader\common.py", line 185, in start_download
response = session.get(self.url, stream=True, timeout=DOWNLOAD_TIMEOUT)
File "C:\Users\OGNGHAFF\AppData\Roaming\Python\Python36\site-packages\requests\sessions.py", line 521, in get
return self.request('GET', url, **kwargs)
File "C:\Users\OGNGHAFF\AppData\Roaming\Python\Python36\site-packages\requests\sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\OGNGHAFF\AppData\Roaming\Python\Python36\site-packages\requests\sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "C:\Users\OGNGHAFF\AppData\Roaming\Python\Python36\site-packages\requests\adapters.py", line 506, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='raw.githubusercontent.com', port=443): Max retries exceeded with url: /DeepScale/SqueezeNet/a47b6f13d30985279789d08053d37013d67d131b/SqueezeNet_v1.1/deploy.prototxt (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),))
########## Error: Download failed**
As suggested in the comments above, make sure to configure your proxy settings for pip if you are behind a proxy server.
Try configuring your http_proxy and https_proxy variables as follows:
set http_proxy=http://[username:password#]proxyserver:port
set https_proxy=https://[username:password#]proxyserver:port

Using Wikipedia Python module give me an SSL Error

When using the python 3 Wikipedia module I get an SSL Certificate error. When is use set StrictSSL false the module works but I don't to do that permanently.
I was wondering if there was something I could change,I saw someone using a verify thing but I'm unsure how.
I am also not on a businesses wifi or anything, I think it is something to do with my computer or the actual code?
Here is the code:
outputs = wikipedia.summary(wikiSearch, sentences=3m)
Here is the error:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 603, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 344, in _make_request
self._validate_conn(conn)
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 843, in _validate_conn
conn.connect()
File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 350, in connect
ssl_context=context)
File "/usr/local/lib/python3.7/site-packages/urllib3/util/ssl_.py", line 355, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 412, in wrap_socket
session=session
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 853, in _create
self.do_handshake()
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 1117, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 641, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 399, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='en.wikipedia.org', port=443): Max retries exceeded with url: /w/api.php?list=search&srprop=&srlimit=1&limit=1&srsearch=alex&srinfo=suggestion&format=json&action=query (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "dave.py", line 42, in <module>
index()
File "dave.py", line 25, in index
outputs = wikipedia.summary(wikiSearch, sentences=3)
File "/usr/local/lib/python3.7/site-packages/wikipedia/util.py", line 28, in __call__
ret = self._cache[key] = self.fn(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/wikipedia/wikipedia.py", line 231, in summary
page_info = page(title, auto_suggest=auto_suggest, redirect=redirect)
File "/usr/local/lib/python3.7/site-packages/wikipedia/wikipedia.py", line 270, in page
results, suggestion = search(title, results=1, suggestion=True)
File "/usr/local/lib/python3.7/site-packages/wikipedia/util.py", line 28, in __call__
ret = self._cache[key] = self.fn(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/wikipedia/wikipedia.py", line 103, in search
raw_results = _wiki_request(search_params)
File "/usr/local/lib/python3.7/site-packages/wikipedia/wikipedia.py", line 737, in _wiki_request
r = requests.get(API_URL, params=params, headers=headers)
File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 668, in send
history = [resp for resp in gen] if allow_redirects else []
File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 668, in <listcomp>
history = [resp for resp in gen] if allow_redirects else []
File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 247, in resolve_redirects
**adapter_kwargs
File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='en.wikipedia.org', port=443): Max retries exceeded with url: /w/api.php?list=search&srprop=&srlimit=1&limit=1&srsearch=alex&srinfo=suggestion&format=json&action=query (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)')))
I hope someone can help! :)

OAuth 2.0 Connection reset by peer

I'm trying to connect to my api, but when I try to fetch access token () or just make a simple request to the endpoint /oauth/authorize, I receive this error :
Traceback (most recent call last):
File "venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 849, in _validate_conn
conn.connect()
File "venv/lib/python3.6/site-packages/urllib3/connection.py", line 356, in connect
ssl_context=context)
File "venv/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 372, in ssl_wrap_socket
return context.wrap_socket(sock)
File "/usr/lib/python3.6/ssl.py", line 407, in wrap_socket
_context=self, _session=session)
File "/usr/lib/python3.6/ssl.py", line 814, in __init__
self.do_handshake()
File "/usr/lib/python3.6/ssl.py", line 1068, in do_handshake
self._sslobj.do_handshake()
File "/usr/lib/python3.6/ssl.py", line 689, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:841)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "venv/lib/python3.6/site-packages/requests/adapters.py", line 445, in send
timeout=timeout
File "venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "venv/lib/python3.6/site-packages/urllib3/util/retry.py", line 398, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='127.0.0.1', port=5000): Max retries exceeded with url: /oauth/authorize?response_type=code&client_id=&state=8SJIlHps6ehUrQhaKQ7h5ADS5o0CZo (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:841)'),))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "api.py", line 14, in <module>
session.fetch_access_token(uri)
File "venv/lib/python3.6/site-packages/authlib/client/oauth2_session.py", line 184, in fetch_access_token
withhold_token=True)
File "venv/lib/python3.6/site-packages/requests/sessions.py", line 559, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "venv/lib/python3.6/site-packages/authlib/client/oauth2_session.py", line 296, in request
method, url, auth=auth, **kwargs)
File "venv/lib/python3.6/site-packages/requests/sessions.py", line 512, in request
resp = self.send(prep, **send_kwargs)
File "venv/lib/python3.6/site-packages/requests/sessions.py", line 622, in send
r = adapter.send(request, **kwargs)
File "venv/lib/python3.6/site-packages/requests/adapters.py", line 511, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='127.0.0.1', port=5000): Max retries exceeded with url: /oauth/authorize?response_type=code&client_id=&state=8SJIlHps6ehUrQhaKQ7h5ADS5o0CZo (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:841)'),))
' Connection reset by peer ' socket error don't work to me. I'm using a https connection locally and the default server from Flask. Some tips ?
Update :
I did try to set the ssl of two ways :
1 º :
import ssl
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
context.load_cert_chain('127.0.0.1+1.pem', '127.0.0.1+1-key.pem')
app.run(ssl_context=context)
2 º :
app.run(ssl_context=('127.0.0.1+1.pem', '127.0.0.1+1-key.pem'))

Categories