我有以下功能:
def soap(self, xml):
""" Transport function """
slash = self.apiurl.find('/')
addr = self.apiurl[:slash]
path = self.apiurl[slash:]
conn = httplib.HTTPSConnection(addr)
conn.putrequest("POST", path)
conn.putheader("Content-type", "text/xml; charset=\"UTF-8\"")
conn.putheader("Content-length", "%d" % len(xml))
conn.endheaders()
conn.send(xml)
rez = conn.getresponse()
content = rez.read()
conn.close()
return rez, content
当我尝试使用此功能连接到服务器时,我收到以下错误:
conn.endheaders()
File "/usr/lib/python2.6/httplib.py", line 908, in endheaders
self._send_output()
File "/usr/lib/python2.6/httplib.py", line 780, in _send_output
self.send(msg)
File "/usr/lib/python2.6/httplib.py", line 739, in send
self.connect()
File "/usr/lib/python2.6/httplib.py", line 1116, in connect
self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file)
File "/usr/lib/python2.6/ssl.py", line 338, in wrap_socket
suppress_ragged_eofs=suppress_ragged_eofs)
File "/usr/lib/python2.6/ssl.py", line 120, in __init__
self.do_handshake()
File "/usr/lib/python2.6/ssl.py", line 279, in do_handshake
self._sslobj.do_handshake()
Python 2.6。奇怪的是,当我尝试连接第二次时 - 它没有任何问题。如何用SSL解决这个问题?我做错了什么?