2011-08-03 22:34:34 +00:00
|
|
|
import socket
|
2010-02-16 04:09:07 +00:00
|
|
|
from SocketServer import BaseServer
|
|
|
|
from BaseHTTPServer import HTTPServer
|
|
|
|
import ssl
|
|
|
|
import handler
|
|
|
|
|
|
|
|
|
|
|
|
class SecureHTTPServer(HTTPServer):
|
|
|
|
def __init__(self, server_address, HandlerClass):
|
|
|
|
BaseServer.__init__(self, server_address, HandlerClass)
|
|
|
|
self.socket = ssl.wrap_socket(
|
|
|
|
socket.socket(self.address_family, self.socket_type),
|
|
|
|
keyfile = "data/serverkey.pem",
|
|
|
|
certfile = "data/serverkey.pem"
|
|
|
|
)
|
|
|
|
self.server_bind()
|
|
|
|
self.server_activate()
|
|
|
|
|
|
|
|
|
|
|
|
def make(port):
|
2012-01-20 23:43:00 +00:00
|
|
|
server_address = ('127.0.0.1', port)
|
2010-02-16 04:09:07 +00:00
|
|
|
return SecureHTTPServer(server_address, handler.TestRequestHandler)
|