Requests / openssl: TypeError: initializer for ctype must be a pointer to the same type, not cdata

I am having a problem with queries that I could not find elsewhere.

I make a mail request to Google with some data containing the client id and tokens (these are just python strings), but I sometimes get this error:

TypeError: initializer for ctype 'int(*)(int, X509_STORE_CTX *)' must be a pointer to same type, not cdata 'int(*)(int, X509_STORE_CTX *)' 

It seems to work every time, and then it sometimes causes this error. I tried to encode all the data / url in "utf-8", but that didn't seem to help much since I still get someimtes error. If I go back to checking = False, this will work, but I would like to keep it. Here is the complete trace:

 url = 'https://accounts.google.com/...' data = {'refresh_token': ..., 'client_id': …, 'client_secret': ..., 'grant_type': 'refresh_token', } File "/path/to/file/file.py", line 124, in _my_function.py response = requests.post(url, data=data) File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 94, in post return request('post', url, data=data, json=json, **kwargs) File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 49, in request return session.request(method=method, url=url, **kwargs) File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 457, in request resp = self.send(prep, **send_kwargs) File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 569, in send r = adapter.send(request, **kwargs) File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 362, in send timeout=timeout File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/connectionpool.py", line 516, in urlopen body=body, headers=headers) File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/connectionpool.py", line 304, in _make_request self._validate_conn(conn) File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/connectionpool.py", line 722, in _validate_conn conn.connect() File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/connection.py", line 229, in connect ssl_version=resolved_ssl_version) File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 255, in ssl_wrap_socket ctx.set_verify(_openssl_verify[cert_reqs], _verify_callback) File "/usr/local/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 550, in set_verify :param depth: An integer specifying the verify depth TypeError: initializer for ctype 'int(*)(int, X509_STORE_CTX *)' must be a pointer to same type, not cdata 'int(*)(int, X509_STORE_CTX *)' 

Using queries 2.4.2 and pyopenssl 0.14. If you have any ideas that would be great, thanks.

Edit: lowering pyopenssl to 0.13 results in an error.

+6
source share
1 answer

@ Fredrick, I face the same problems, you can tell me how you decided

0
source

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


All Articles