It's really simple. You have to install (at least) TLSlite. (M2Crypto
and OpenSSL are also recommended)
Create a copy of SimpleAsyncHTTPServer.py as
SimpleAsyncHTTPSServer.py. Then apply the following additions or
changes:
in the Import section add:
from tlslite.api import *
s = open("./serverX509Cert.pem").read()
x509 = X509()
x509.parse(s)
certChain = X509CertChain([x509])
s = open("./serverX509Key.pem").read()
privateKey = parsePEMKey(s, private=True)
sessionCache = SessionCache()
(the files serverX509Cert.pem and serverX509Key.pem are taken from the
test folder of TSLlite; they are not valid any more but still work for
testing. I did not manage to create may own pem files yet. Place them
in the main Karrigell folder.)
in class server, the function accept_new_client hast to be replaced
with the following:
def accept_new_client(self):
try:
request, client_address = self.socket.accept()
connection = TLSConnection(request)
connection.handshakeServer(certChain=certChain,privateKey=privateKey,sessionCache=sessionCache)
connection.settimeout(0)
except TLSError:
return
self.client_handlers[request] = self.RequestHandlerClass(self,
connection, client_address)
Now modify the Karrigell.py script (or a copy named "Karrigell
SSL.py") to import from SimpleAsyncHTTPSServer.py instead of
SimpleAsyncHTTPServer.py.
That's all. If you do not use port 443, you have to set the port in
your browser, like "https://localhost:8080".
All the demos etc. seem to work fine. I have not adapted my own
applications to Karrigell 2.4 yet.
Guenter