I want to add ssl support to an existing TCP server, which is based on the SocketServer.TCPServer class. So I redefined the default constructor of the TCPServer class and added ssl.wrap_socket (...) - call:
class MyTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer): def __init__(self, server_address, RequestHandlerClass, bind_and_activate=True):
When starting the server, an error does not occur. Therefore, I modified my simple test client to support ssl:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock = ssl.wrap_socket(s) sock.connect(('192.168.1.1', 54321))
Again, the error does not occur, but the call connection is blocked. When closing the client using Ctrl + C, it shows the following:
Traceback (most recent call last): File "exampleClient.py", line 10, in <module> sock.do_handshake() File "/usr/lib/python2.6/ssl.py", line 293, in do_handshake self._sslobj.do_handshake() KeyboardInterrupt
Thus, do_handshake is blocked when connected. Does anyone know how to solve a problem? I just want to use an encrypted TCP connection :)
source share