[Twisted-web] HTTPS in Twisted
edugnani at gmail.com
Tue Feb 12 08:32:24 EST 2008
On Feb 8, 2008 9:10 PM, Colin Alston <karnaugh at karnaugh.za.net> wrote:
> Change TCPServer to SSLServer. Will also help to read the API docs.
Thanks for the tip.
Using that, I discovered that I had to generate a private key file,
and then generate a self-signed SSL certificate..
After that, I just created a ssl context with the private key and
the certificate and changed my call "reactor.listenTCP()" to
"reactor.listenSSL()", passing the ssl context as parameter.
Here is the code if anyone wants:
from twisted.web import http
... my processing code
requestFactory = MyRequestHandler
protocol = MyHttp
if __name__ == "__main__":
from twisted.internet import reactor, ssl
sslContext = ssl.DefaultOpenSSLContextFactory('privkey.pem','cacert.pem')
reactor.listenSSL(TCP_PORT, MyHttpFactory( ), contextFactory = sslContext)
Link for reference:
More information about the Twisted-web