Requests.exceptions.SSLError: Errno 185090050

I am trying to make .py in .exe. In .py, the application works fine, but after creating it in .exe using py2exe, I get this error:

Traceback (most recent call last): File "filename.py", line 210, in <module> File "requests\api.pyc", line 55, in get File "requests\api.pyc", line 44, in requests File "requests\sessions.pyc", line 461, in request File "requests\sessions.pyc", line 567, in send File "requests\adapters.pyc", line 399, in send requests.exceptions.SLLError: [Errno 185090050] _ssl.c:344: error: 0B084002:x509 certificate routines: X509_load_cert_crl_file:system lib 

And line 210 in the file is

 r2 = requests.get('https://www.hitbox.tv/api/chat/servers', timeout=timeoutDefault) 

This is setup.py:

 from distutils.core import setup import py2exe setup(console=['filename.py']) 

How can I solve this problem?

+6
source share
2 answers

The requests module (or actually urllib3 under it) cannot open the CA certificate file.

If you do not want to verify the server certificate, you can change the call:

 r2 = requests.get('https://www.hitbox.tv/api/chat/servers', timeout=timeoutDefault, verify=False) 

If you need certificates (and you must), make sure that the CA certificate file is associated with your application. According to the requests documentation:

You can also pass the path to the CA_BUNDLE file for private. certificates You can also set the environment variable REQUESTS_CA_BUNDLE.

Requests can also ignore SSL certificate validation; if you set, check the value is False.

See here: http://docs.python-requests.org/en/latest/user/advanced/#ssl-cert-verification

+5
source

I worked on this by decapitating requests to pass cacert.pem :

 def _monkey_patch_requests(): orig_send = HTTPAdapter.send def _send_no_verify(self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None): return orig_send(self, request, stream, timeout, 'cacert.pem' if verify else False, cert, proxies) HTTPAdapter.send = _send_no_verify _monkey_patch_requests() 

and copying <Python>/Lib/site-packages/certifi/cacert.pem to dist .

+1
source

Source: https://habr.com/ru/post/972887/


All Articles