我已经更新到Python 2.7.14,它应该支持TLSv1.2但仍然不起作用

时间:2017-12-04 16:00:16

标签: python python-2.7 ssl tls1.2

我有一个具有TLSv1.2证书的https网址,我已经从2.7.9更新到Python 2.7.14,它应该支持TLSv1.2但仍然不起作用:

>>> import urllib>>> urllib.urlopen(url)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\urllib.py", line 87, in urlopen
    return opener.open(url)
  File "C:\Python27\lib\urllib.py", line 213, in open
    return getattr(self, name)(url)
  File "C:\Python27\lib\urllib.py", line 443, in open_https
    h.endheaders(data)
  File "C:\Python27\lib\httplib.py", line 1038, in endheaders
    self._send_output(message_body)
  File "C:\Python27\lib\httplib.py", line 882, in _send_output
    self.send(msg)
  File "C:\Python27\lib\httplib.py", line 844, in send
    self.connect()
  File "C:\Python27\lib\httplib.py", line 1263, in connect
    server_hostname=server_hostname)
  File "C:\Python27\lib\ssl.py", line 363, in wrap_socket
    _context=self)
  File "C:\Python27\lib\ssl.py", line 611, in __init__
    self.do_handshake()
  File "C:\Python27\lib\ssl.py", line 840, in do_handshake
    self._sslobj.do_handshake()
IOError: [Errno socket error] [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:661)

1 个答案:

答案 0 :(得分:1)

这是一个复杂的问题

  1. 网址要求TLSv1.2(2.7.9不支持)我有
  2. 不支持https的代理
  3. 虽然我修正了1.另一个问题(2.)给出了同样的错误

    <强>解决方案:

      通过升级到Python 2.7.14 修复了
    1. 我所代理的代理不支持https所以我添加并执行了,现在它可以正常工作
    2. (将“for all protocols”复选框保留为空,对于安全部分,将地址和端口保留为空)

      enter image description here