HTTPS server with the new Karrigell 2.4 version.


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,sessio­nCache=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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值