Macbook SSL issue 'Certificate too weak' - python

I have been working on some scripts in python and on https connections I get issue of SSL certificates, especially the self-signed ones. Those are easily over come this particular issue I have with one server is off too weak certificate. Now the server is known to me but not owned by me so I cannot change the certificate. Is there a way to overcome this? I am using a Macbook and the library is an SDK of Solarwinds
Traceback (most recent call last):
File "/Users/networkautomator/VENV/sdkorion/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "/Users/networkautomator/VENV/sdkorion/lib/python3.10/site-packages/urllib3/connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "/Users/networkautomator/VENV/sdkorion/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1042, in _validate_conn
conn.connect()
File "/Users/networkautomator/VENV/sdkorion/lib/python3.10/site-packages/urllib3/connection.py", line 414, in connect
self.sock = ssl_wrap_socket(
File "/Users/networkautomator/VENV/sdkorion/lib/python3.10/site-packages/urllib3/util/ssl_.py", line 453, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls)
File "/Users/networkautomator/VENV/sdkorion/lib/python3.10/site-packages/urllib3/util/ssl_.py", line 495, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 513, in wrap_socket
return self.sslsocket_class._create(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1071, in _create
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1342, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: EE certificate key too weak (_ssl.c:997)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/networkautomator/VENV/sdkorion/lib/python3.10/site-packages/requests/adapters.py", line 489, in send
resp = conn.urlopen(
File "/Users/networkautomator/VENV/sdkorion/lib/python3.10/site-packages/urllib3/connectionpool.py", line 787, in urlopen
retries = retries.increment(
File "/Users/networkautomator/VENV/sdkorion/lib/python3.10/site-packages/urllib3/util/retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='10.1.6.200', port=17778): Max retries exceeded with url: /SolarWinds/InformationService/v3/Json/Query (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: EE certificate key too weak (_ssl.c:997)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/networkautomator/VENV/sdkorion/query_test_2.py", line 14, in <module>
results = swis.query("SELECT NodeID, DisplayName, NodeDescription FROM Orion.Nodes Where SysName LIKE 'VELO%'")
File "/Users/networkautomator/VENV/sdkorion/lib/python3.10/site-packages/orionsdk/swisclient.py", line 23, in query
return self._req(
File "/Users/networkautomator/VENV/sdkorion/lib/python3.10/site-packages/orionsdk/swisclient.py", line 52, in _req
resp = self._session.request(method,
File "/Users/networkautomator/VENV/sdkorion/lib/python3.10/site-packages/requests/sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
File "/Users/networkautomator/VENV/sdkorion/lib/python3.10/site-packages/requests/sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
File "/Users/networkautomator/VENV/sdkorion/lib/python3.10/site-packages/requests/adapters.py", line 563, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='10.20.5.1', port=17778): Max retries exceeded with url: /SolarWinds/InformationService/v3/Json/Query (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: EE certificate key too weak (_ssl.c:997)')))
All help regarding this will be appreciated.
Thanks

Related

SSLError: HTTPSConnectionPool with "paddleocr"

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

requests is giving error 'certificate verify failed: unable to get local issuer certificate (_ssl.c:997)'

When I run my program that uses the requests module to send info to an api, I get the error:
requests.exceptions.SSLError: HTTPSConnectionPool(host='www.fast2sms.com', port=443): Max retries exceeded with url: /dev/bulkV2?authorization=vQWJE07LzxhrR8TM1lDBUK6gASOPy4miVnkf3bHXGZNs9YcI2o3GScblwJY7kmx1rpDWuBnLhVH54vKC&sender_id=TXTIND&route=v3&language=unicode&numbers=14372341004&message=FastSMS+test%0A (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')))
I've gotten this error before when using requests, I just never tried to fix it.
Full error code:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connectionpool.py", line 1040, in _validate_conn
conn.connect()
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connection.py", line 414, in connect
self.sock = ssl_wrap_socket(
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\util\ssl_.py", line 449, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\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\user1\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 512, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 1070, in _create
self.do_handshake()
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 1341, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\adapters.py", line 440, in send
resp = conn.urlopen(
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connectionpool.py", line 785, in urlopen
retries = retries.increment(
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\util\retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www.fast2sms.com', port=443): Max retries exceeded with url: /dev/bulkV2?authorization=vQWJE07LzxhrR8TM1lDBUK6gASOPy4miVnkf3bHXGZNs9YcI2o3GScblwJY7kmx1rpDWuBnLhVH54vKC&sender_id=TXTIND&route=v3&language=unicode&numbers=14372341004&message=FastSMS+test%0A (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 1921, in __call__
return self.func(*args)
File "c:\Users\user1\AppData\Local\Temp\Temp1_Pythonista_ForAll-main.zip\Pythonista_ForAll-main\SMS_Sender\SMSAutomation.py", line 25, in btn_clk
r = send_sms(num,msg)
File "c:\Users\user1\AppData\Local\Temp\Temp1_Pythonista_ForAll-main.zip\Pythonista_ForAll-main\SMS_Sender\SMSAutomation.py", line 17, in send_sms
response = requests.get(url, params=prams)
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\sessions.py", line 529, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\sessions.py", line 645, in send
r = adapter.send(request, **kwargs)
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\adapters.py", line 517, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='www.fast2sms.com', port=443): Max retries exceeded with url: /dev/bulkV2?authorization=vQWJE07LzxhrR8TM1lDBUK6gASOPy4miVnkf3bHXGZNs9YcI2o3GScblwJY7kmx1rpDWuBnLhVH54vKC&sender_id=TXTIND&route=v3&language=unicode&numbers=14372341004&message=FastSMS+test%0A (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')))

Python requests basic command returns errors - what's wrong?

I want to run these 3 commands:
import requests
result = requests.get("https://somedomain.xyz/start_page.html")
print(result.status_code)
but I get an error output:
Traceback (most recent call last):
File "C:\Users\usik\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 670, in urlopen
httplib_response = self._make_request(
File "C:\Users\usik\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 381, in _make_request
self._validate_conn(conn)
File "C:\Users\usik\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 978, in _validate_conn
conn.connect()
File "C:\Users\usik\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connection.py", line 362, in connect
self.sock = ssl_wrap_socket(
File "C:\Users\usik\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\util\ssl_.py", line 386, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\usik\AppData\Local\Programs\Python\Python38-32\lib\ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\usik\AppData\Local\Programs\Python\Python38-32\lib\ssl.py", line 1040, in _create
self.do_handshake()
File "C:\Users\usik\AppData\Local\Programs\Python\Python38-32\lib\ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1108)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\usik\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\adapters.py", line 439, in send
resp = conn.urlopen(
File "C:\Users\usik\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 726, in urlopen
retries = retries.increment(
File "C:\Users\usik\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\util\retry.py", line 446, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='somedomain.xyz', port=443): Max retries exceeded with url: /bzo/en/start_page.html (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1108)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python\TTNr.py", line 8, in
result = requests.get("https://somedomain.xyz/start_page.html")
File "C:\Users\usik\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\api.py", line 76, in get
return request('get', url, params=params, **kwargs)
File "C:\Users\usik\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\usik\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\usik\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "C:\Users\usik\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\adapters.py", line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='somedomain.xyz', port=443): Max retries exceeded with url: /start_page.html (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1108)')))
Does anyone know what could be a problem and how to solve it? Thanks in advance.
import requests
result = requests.get("https://somedomain.xyz/start_page.html", verify=False)
print(result.status_code)
If you don't want to keep verify=False, then the path of the relevant certs need to be mentioned here.
You seem to be accessing a site that uses a self-signed certificate. That will not be considered valid by default.
Have a look at: How to get Python requests to trust a self signed SSL certificate?

SSL error after "download" call from yfinance

I installed yfinance in Spyder (Python 3.7) but when I make a basic call, such as:
import yfinance as yf
df_yahoo = yf.download('AAPL',
start='2000-01-01',
end='2010-12-31',
progress=False)
print(df_yahoo)
I get an error message:
Exception in thread Thread-9: Traceback (most recent call last):
File
"c:\users\miniconda3\lib\site-packages\urllib3\connectionpool.py",
line 672, in urlopen
chunked=chunked, File "c:\users/miniconda3\lib\site-packages\urllib3\connectionpool.py",
line 376, in _make_request
self._validate_conn(conn) File "c:\users\miniconda3\lib\site-packages\urllib3\connectionpool.py",
line 994, in validate_conn
conn.connect() File "c:\users\miniconda3\lib\site-packages\urllib3\connection.py",
line 360, in connect
ssl_context=context, File "c:\users\miniconda3\lib\site-packages\urllib3\util\ssl.py",
line 370, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname) File "c:\users\miniconda3\lib\ssl.py", line 423, in
wrap_socket
session=session File "c:\users\miniconda3\lib\ssl.py", line 870, in _create
self.do_handshake() File "c:\users\miniconda3\lib\ssl.py", line 1139, in do_handshake
self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed
certificate in certificate chain (_ssl.c:1076)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"c:\users\miniconda3\lib\site-packages\requests\adapters.py",
line 449, in send
timeout=timeout File "c:\users\miniconda3\lib\site-packages\urllib3\connectionpool.py",
line 720, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2] File
"c:\users\miniconda3\lib\site-packages\urllib3\util\retry.py",
line 436, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError:
HTTPSConnectionPool(host='query1.finance.yahoo.com', port=443): Max
retries exceeded with url:
/v8/finance/chart/AAPL?period1=946681200&period2=1293750000&interval=1d&includePrePost=False&events=div%2Csplits
(Caused by SSLError(SSLCertVerificationError(1, '[SSL:
CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed
certificate in certificate chain (_ssl.c:1076)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"c:\users\miniconda3\lib\threading.py", line 926, in
_bootstrap_inner
self.run() File "c:\users\miniconda3\lib\threading.py", line 870, in run
self._target(*self._args, **self.kwargs) File "c:\users\miniconda3\lib\site-packages\multitasking_init.py",
line 102, in _run_via_pool
return callee(*args, **kwargs) File "c:\users\miniconda3\lib\site-packages\yfinance\multi.py",
line 167, in _download_one_threaded
actions, period, interval, prepost, proxy, rounding) File "c:\users\miniconda3\lib\site-packages\yfinance\multi.py",
line 182, in _download_one
rounding=rounding, many=True) File "c:\users\miniconda3\lib\site-packages\yfinance\base.py",
line 150, in history
data = _requests.get(url=url, params=params, proxies=proxy) File "c:\users\miniconda3\lib\site-packages\requests\api.py",
line 76, in get
return request('get', url, params=params, **kwargs) File "c:\users\miniconda3\lib\site-packages\requests\api.py",
line 61, in request
return session.request(method=method, url=url, **kwargs) File "c:\users\miniconda3\lib\site-packages\requests\sessions.py",
line 530, in request
resp = self.send(prep, **send_kwargs) File "c:\users\miniconda3\lib\site-packages\requests\sessions.py",
line 643, in send
r = adapter.send(request, **kwargs) File "c:\users\miniconda3\lib\site-packages\requests\adapters.py",
line 514, in send
raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='query1.finance.yahoo.com', port=443): Max
retries exceeded with url:
/v8/finance/chart/AAPL?period1=946681200&period2=1293750000&interval=1d&includePrePost=False&events=div%2Csplits
(Caused by SSLError(SSLCertVerificationError(1, '[SSL:
CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed
certificate in certificate chain (_ssl.c:1076)')))
Moreover, Spyder seems to get stuck in some sort of loop and I have to manually interrupt it.
Can anyone help me here?
Many thanks
I believe the problem comes from an external source, maybe Yahoo Finance was down? I tried running your code and it works fine for me. (PyCharm, Python 3.7)
On MacOS Big Sur, You need to install the certificate in Python 3.9.
cd /Applications/Python\ 3.9/
./Install\ Certificates.command

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