1 from SocketServer import *
2 from BaseHTTPServer import *
3 from SimpleHTTPServer import *
4 from tlslite.api import *
6 s = open("./serverX509Cert.pem").read()
9 certChain = X509CertChain([x509])
11 s = open("./serverX509Key.pem").read()
12 privateKey = parsePEMKey(s, private=True)
14 sessionCache = SessionCache()
16 class MyHTTPServer(ThreadingMixIn, TLSSocketServerMixIn, HTTPServer):
17 def handshake(self, tlsConnection):
19 tlsConnection.handshakeServer(certChain=certChain,
20 privateKey=privateKey,
21 sessionCache=sessionCache)
22 tlsConnection.ignoreAbruptClose = True
24 except TLSError, error:
25 print "Handshake failure:", str(error)
28 httpd = MyHTTPServer(('localhost', 443), SimpleHTTPRequestHandler)