[Python] Problema con sito https

Riccardo Lemmi riccardo a reflab.com
Lun 24 Mar 2014 12:17:22 CET


Dario Bertini wrote:

> Riccardo, curioso che a te funzioni: leggi il mio messaggio, che
> spiega il problema
> 
> forse a te funziona perchè hai una versione diversa di openssl?
> 
> puoi darci l'output di
> python -c "import ssl; print(ssl.OPENSSL_VERSION)"
> 
> e di
> 
> curl -v 'https://www.u-gov.sssup.it'
> 
> ?
> 

Certo, ecco qua:

 $ python -c "import ssl; print(ssl.OPENSSL_VERSION)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'OPENSSL_VERSION'

Questo è un python 2.6.5: interessante :D

Con un python 2.7 compilato da me:

 $ /opt/python-2.7.2/bin/python -c "import ssl; 
print(ssl.OPENSSL_VERSION)"
OpenSSL 0.9.8k 25 Mar 2009

e funziona ancora il codice sopra mentre con un python 3.1 (sempre 
compilato da me, sullo stessa macchina degli altri due interpreti:

>>> import urllib.request as urllib2
>>> x=urllib2.urlopen('https://www.u-gov.sssup.it')
Traceback (most recent call last):
  File "/opt/python-3.1.1/lib/python3.2/urllib/request.py", line 1136, 
in do_open
    h.request(req.get_method(), req.selector, req.data, headers)
  File "/opt/python-3.1.1/lib/python3.2/http/client.py", line 964, in 
request
    self._send_request(method, url, body, headers)
  File "/opt/python-3.1.1/lib/python3.2/http/client.py", line 1002, in 
_send_request
    self.endheaders(body)
  File "/opt/python-3.1.1/lib/python3.2/http/client.py", line 960, in 
endheaders
    self._send_output(message_body)
  File "/opt/python-3.1.1/lib/python3.2/http/client.py", line 805, in 
_send_output
    self.send(msg)
  File "/opt/python-3.1.1/lib/python3.2/http/client.py", line 743, in 
send
    self.connect()
  File "/opt/python-3.1.1/lib/python3.2/http/client.py", line 1105, in 
connect
    server_hostname=server_hostname)
  File "/opt/python-3.1.1/lib/python3.2/ssl.py", line 179, in 
wrap_socket
    _context=self)
  File "/opt/python-3.1.1/lib/python3.2/ssl.py", line 266, in __init__
    raise x
  File "/opt/python-3.1.1/lib/python3.2/ssl.py", line 262, in __init__
    self.do_handshake()
  File "/opt/python-3.1.1/lib/python3.2/ssl.py", line 441, in 
do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [Errno 1] _ssl.c:392: error:14077417:SSL 
routines:SSL23_GET_SERVER_HELLO:sslv3 alert illegal parameter

e il curl:

 $ curl -v 'https://www.u-gov.sssup.it'
* About to connect() to www.u-gov.sssup.it port 443 (#0)
*   Trying 193.205.80.7... connected
* Connected to www.u-gov.sssup.it (193.205.80.7) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* error:14077417:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert illegal 
parameter
* Closing connection #0
curl: (35) error:14077417:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 
alert illegal parameter

-- 
                                       Riccardo Lemmi


Maggiori informazioni sulla lista Python