import os, sys import socket import time import SSLCommon import SocketServer response = "pong" * 20 class ReqHandler(SocketServer.StreamRequestHandler): def handle(self): print "Starting handler" # Read the request string = self.rfile.read(100) if len(string) > 0: print "request was: '%s' (%d)" % (string, len(string)) else: print "request was zero-length" # Write the response self.wfile.write(response) if __name__ == '__main__': if len(sys.argv) < 4: print "Usage: python %s key_and_cert ca_cert peer_ca_cert" % sys.argv[0] sys.exit(1) certs = {} certs['key_and_cert'] = sys.argv[1] certs['ca_cert'] = sys.argv[2] certs['peer_ca_cert'] = sys.argv[3] print "Starting the server." server = SSLCommon.PlgBaseSSLServer(('localhost', 8888), ReqHandler, certs) server.serve_forever()