R
R
Ruslan Khairullin2016-02-01 09:40:39
Python
Ruslan Khairullin, 2016-02-01 09:40:39

curl request error over https protocol?

I wrote a script for python 3.4.3 that uses the requests library. On a computer running Linux Mint, everything starts up fine, data is requested and received. Began to transfer to a virtual machine running Ubuntu Server 15.10. I ran the script and it hung. I started digging and got to the line where the post request to the server takes place using the https protocol.

import requests
pl = {'test':'test'}
r = requests.Session()
r.post("https://toster.ru",verify=False,data=pl)

I tried to simply duplicate the code with commands and when the request freezes, I press Ctrl + C and I get the following:
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 780, in _validate_conn
    conn.connect()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 241, in connect
    ssl_version=resolved_ssl_version)
  File "/usr/lib/python3/dist-packages/urllib3/util/ssl_.py", line 276, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/lib/python3.4/ssl.py", line 362, in wrap_socket
    _context=self)
  File "/usr/lib/python3.4/ssl.py", line 580, in __init__
    self.do_handshake()
  File "/usr/lib/python3.4/ssl.py", line 807, in do_handshake
    self._sslobj.do_handshake()
KeyboardInterrupt

Seeing the process hang on the sslobj.do_handshake() process. I tried to make a curl request (for example, the request was made to https://toster.ru):
curl -v https://toster.ru
* Rebuilt URL to: https://toster.ru/
*   Trying 178.248.236.52...
* Connected to toster.ru (178.248.236.52) port 443 (#0)
* found 187 certificates in /etc/ssl/certs/ca-certificates.crt
* found 748 certificates in /etc/ssl/certs
* ALPN, offering http/1.1

And the process also hung.
Similarly with gnutls:
Processed 187 CA certificate(s).
Resolving 'toster.ru'...
Connecting to '178.248.236.52:443'...
*** Fatal error: The operation timed out
*** Handshake has failed
GnuTLS error: The operation timed out

Versions:
OpenSSL 1.0.2d 9 Jul 2015
gnutls-cli 3.3.15
curl 7.43.0 (x86_64-pc-linux-gnu) libcurl/7.43.0 GnuTLS/3.3.15 zlib/1.2.8 libidn/1.28 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP UnixSockets

I must say right away that I don’t understand the settings of all this, but I ask you to direct me in the right direction.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2016-02-01
@ruha02

stackoverflow.com/questions/29134512/insecureplatf...
pip install 'requests[security]'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question