1 2from tlslite.api import * 3import socket 4 5s = socket.socket() 6 7s.connect( ("localhost", 1079) ) 8 9""" 10#Only use this for Echo2 11s.send("000\r\n") 12while 1: 13 val= s.recv(100) 14 print val, 15 if val.endswith("000\r\n"): 16 break 17 18s.send("STARTTLS\r\n") 19""" 20 21connection = TLSConnection(s) 22#connection.handshakeClientNoAuth() 23connection.handshakeClientSRP("test", "password") 24 25connection.send("abc\r\n") 26print connection.recv(100), 27print connection.recv(100), 28 29connection.send("def\r\n") 30print connection.recv(100), 31 32connection.close() 33connection.sock.close()