Python 3 https连接通过套接字

时间:2013-02-17 18:55:52

标签: python sockets web python-3.x

我需要通过套接字使用https连接(使用socks代理),我正在尝试使用ssl但是收到错误:

>>> import socket
>>> import ssl
>>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>> s.connect(("www.google.com.ua",443))
>>> ss=ssl.wrap_socket(s)
Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    ss=ssl.wrap_socket(s)
  File "/usr/lib/python3.2/ssl.py", line 521, in wrap_socket
    ciphers=ciphers)
  File "/usr/lib/python3.2/ssl.py", line 276, in __init__
    raise x
  File "/usr/lib/python3.2/ssl.py", line 272, in __init__
    self.do_handshake()
  File "/usr/lib/python3.2/ssl.py", line 451, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [Errno 8] _ssl.c:392: EOF occurred in violation of protocol

我怎样才能做对? Thnx提前。

0 个答案:

没有答案