aboutsummaryrefslogtreecommitdiffstats
path: root/test/sslserv.py
blob: 557ce8697637e5169f6b51fc28c8f5ef8b1645ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import socket
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):
    server_address = ('127.0.0.1', port)
    return SecureHTTPServer(server_address, handler.TestRequestHandler)