Home > Uncategorized > Setting up an HTTPS (SSL) Server using CherryPy

Setting up an HTTPS (SSL) Server using CherryPy

With CherryPy (version 3.2.2) its pretty easy to quickly come with an HTTPS server in addition to an HTTP server. Basically, all you need to do as extra work is setting up the required SSL libraries (pyOpenSSL) and getting a certificate and a private key (which comes with the certificate). pyOpenSSL is an interface to OpenSSL library so first you need to set up OpenSSL then download and install pyOpenSSL from here. You may also need to add OpenSLL to your path variable so keep that in mind if there seems to be something wrong during setup. Also make sure that your Python is 32-bit or otherwise it can be very painful to set up openSSL and pyOpenSSL since they don’t have readily available 64-bit distributions. You can either buy a certificate (e.g. from Go Daddy) or generate your own self-signed certificate and use that. In my case since we were using a test server, I generated a self-signed certificate which I will talk about in another post.

After you have everything you can simply set up your server as shown below:

import cherrypy

class RootServer:
    def index(self, **keywords):
        return "it works!"

if __name__ == '__main__':
        'server.socket_host': '',

        # this is optional


In one of the next posts I will describe how to set up a server for uploading files that serves both over HTTP and HTTPS.

References: http://www.zacwitte.com/using-ssl-https-with-cherrypy-3-2-0-example

Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: