OLD | NEW |
| (Empty) |
1 from SocketServer import * | |
2 from BaseHTTPServer import * | |
3 from SimpleHTTPServer import * | |
4 from tlslite.api import * | |
5 | |
6 s = open("./serverX509Cert.pem").read() | |
7 x509 = X509() | |
8 x509.parse(s) | |
9 certChain = X509CertChain([x509]) | |
10 | |
11 s = open("./serverX509Key.pem").read() | |
12 privateKey = parsePEMKey(s, private=True) | |
13 | |
14 sessionCache = SessionCache() | |
15 | |
16 class MyHTTPServer(ThreadingMixIn, TLSSocketServerMixIn, HTTPServer): | |
17 def handshake(self, tlsConnection): | |
18 try: | |
19 tlsConnection.handshakeServer(certChain=certChain, | |
20 privateKey=privateKey, | |
21 sessionCache=sessionCache) | |
22 tlsConnection.ignoreAbruptClose = True | |
23 return True | |
24 except TLSError, error: | |
25 print "Handshake failure:", str(error) | |
26 return False | |
27 | |
28 httpd = MyHTTPServer(('localhost', 443), SimpleHTTPRequestHandler) | |
29 httpd.serve_forever() | |
OLD | NEW |